Webservice

1.對Web服務的請求是否可以穿越防火牆?(25分)
A: 可以,因为web service和website使用同样的端口(默认80),一般防火墙不会封这个端口。

2.在Web服務的服務端產生的異常,如何發送給客戶端?(25分)
A:SoapException。WebService端产生的异常,都会被一个新的SoapException包裹起来,并发送给客户端
MSND上的原话:The SoapException can either be thrown by the common language runtime or by an XML Web service method. The common language runtime can throw a SoapException if a response to a request is not formatted correctly. XML Web service methods can generate a SoapException by simply throwing an exception within the XML Web service method. If the client accessed the method over SOAP, the exception is caught on the server and wrapped inside a new SoapException. 

3.Web服務系統的設計與面向對象系統的設計有何不同?(25分)
A: WebService内部可以使用面向对象系统设计,但是暴露的接口(WebMethod)是不能使用面向对象。因为继承体系是无法传递给客户端
例如
class Car
{
    ....
}
class Ford : Car
{
    ....
}

[WebMethod]
public Car BuildCar()
{
     return new Ford();
}

这样,虽然么有编译错误,但是运行时却得到错误。

4.WebMethod可以返回DataSet類型,那是否可以返回DataTable類型呢?為何?(25分)
A: 可以返回DataTable,因为DataTable实现了ISerializable接口

posted @ 2012-05-21 19:39  凌绝顶  阅读(189)  评论(0)    收藏  举报