wsdl service-soap-client

lubomir2023

New member
Joined
Aug 8, 2023
Messages
3
Programming Experience
1-3
Can you help me with simple code ? I like to try free wsdl test service page from w3schools.
www
wsdl

i use visual basic / VS2019 / , created one button on form1, i add service reference , and i wrote this code.

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim client As New ServiceReference1.TempConvertSoapClient
Dim response As String
response = client.CelsiusToFahrenheit("20")
MsgBox("vysledok: " & response)
client.Close()
End Sub
End Class

but it doesnt work.
Any idea what to do ? I am really new in web service....
thx
 
It returns an error page and not a Soap response, probably out of service. You can invoke the methods manually in browser, there you see the error page.
 
tjhx for answer, but i cant agree, that its out of service. I tried SOAP UI testing software. I used same wsdl file, i sent request and i got response. See attached file. Maybe another idea ?
 

Attachments

  • soapui_priklad3.JPG
    soapui_priklad3.JPG
    199.6 KB · Views: 54
For me it looks like the WSDL is not updated after service was moved from Http to Https - service addresses in Wsdl is still Http, but if you request that you get a 301 Moved Permanently (to Https) and a Html error page in response. I'm guessing SOAP UI follow that redirect and makes a new request, while the .Net client throws ProtocolException:
The content type text/html;charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8).
Not sure what can be done about the generated configuration files, but this works for me in code:
VB.NET:
Dim binding As New ServiceModel.BasicHttpsBinding()
Dim address As New ServiceModel.EndpointAddress("https://www.w3schools.com/xml/tempconvert.asmx")
Dim client As New ServiceReference1.TempConvertSoapClient(binding, address)
 
Great, thanks, you are right. And for anyone who wants to learn a little about wsdl, here is whole code, for 1 button, 1 textbox for input in Celsius, and MsgBox writes returned value in Fahrenheit.. / for wsdl in first post/

Public Class Form1

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim binding As New ServiceModel.BasicHttpsBinding()
Dim address As New ServiceModel.EndpointAddress("TempConvert Web Service")
Dim client As New ServiceReference1.TempConvertSoapClient(binding, address)
Dim response As String
response = client.CelsiusToFahrenheit(TextBox1.Text)
MsgBox("Output: " & response)
client.Close()

End Sub
End Class
 
Back
Top