在我的soapclient中捕获异常

时间:2012-02-24 19:45:35

标签: vb.net web-services wsdl soap-client soapfault

this link获取TripPriceService.wsdl通过从保存在本地文件夹中的提到的wsdl文件中提供wsdl,将服务引用(ServiceReference1)添加到Windows应用程序。我的问题有两个部分

1)根据wsdl(TripPriceServiceException),以下故障消息是否为有效的soap故障?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:trip="http://trip.price.service">
   <soapenv:Header/>
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:client</faultcode>
         <faultstring>error</faultstring>
         <detail>
            <trip:TripPriceServiceException/>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

2)现在当响应是soap:fault?

时,如何处理和捕获详细信息标记
Imports windowsapp1.ServiceReference1
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim obj As New ServiceReference1.TripPriceServiceFacadeClient
        Dim abc As New ServiceReference1.trip
        Dim a As Single
        Dim d As ServiceReference1.TripPriceServiceException
        a = obj.getTripPrice(abc)
    End Sub
End Class

行obj.getTripPrice,调用服务。但是,如果响应是soap错误(类型为TripPriceServiceException),它会抛出异常吗?如何处理这种情况,我们需要使用ServiceReference1.TripPriceServiceException吗?我只是用这个wsdl来解释我目前的情况。我们需要在我们的Web服务客户端中处理这些错误。

1 个答案:

答案 0 :(得分:0)

也许我不明白你的问题。为什么不使用Try / Catch / End Try块并捕获TripPriceServiceException?