Question

Take the TripPriceService.wsdl from this link Add a service reference(ServiceReference1) to a windows application, by giving the wsdl from the mentioned wsdl file saved in local folder. My question has two parts

1) Is the below fault message a valid soap fault as per the wsdl(TripPriceServiceException)?

<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)Now How to handle and catch the detail tag, when the response is a 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

The line obj.getTripPrice, invokes the service. However will it throw an exception if the response is a soap fault(of type TripPriceServiceException)? How to handle such cases, do we need to use ServiceReference1.TripPriceServiceException?I just used this wsdl to explain my current situation. We are in a need to handle such faults in our webservice client.

Was it helpful?

Solution

Maybe I don't understand your question. Why would you not use a Try/Catch/End Try block and catch TripPriceServiceException?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top