Visual Studio 2019 - ASPX.vb = Webservices SOAP requests RRS feed

  • Question

  • Hello everyone,

    I am new to webservices and I am trying to establish a simple page to consume a webservice based on what the user submits.

    If I try to use Boomerang or SOAPUI my requests are successful, but I try the same requests via code I get an error message :

      Message=The underlying connection was closed: An unexpected error occurred on a send.
      Source=<Cannot evaluate the exception source>
    <Cannot evaluate the exception stack trace>
    Inner Exception 1:
    IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

    Inner Exception 2:
    SocketException: An existing connection was forcibly closed by the remote host

    Here is what the webservice is expecting: 

    <soapenv:Envelope xmlns:soapenv="" xmlns:mob="" xmlns:java="">

    Here is my code :


    Public Class _Default
        Inherits Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        End Sub
        Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim loginXML As String, InputXML As String, MethodName As String
            MethodName = txtMethodNm.Text.Trim
            loginXML = "<![CDATA[<mobileLogonForm><username>" & txtUserId.Text.Trim & "</username><password>" & txtPassword.Text.Trim & "</password></mobileLogonForm>]]>"
            InputXML = "<![CDATA[<workerInfoInputForm><loginId>" & txtInputVar.Text.Trim & "</loginId></workerInfoInputForm>]]>"
            InvokeWebService(MethodName, loginXML, InputXML)
        End Sub
        Private Sub InvokeWebService(ByVal arg1 As String, ByVal arg2 As String, ByVal arg3 As String)
            Dim mobileservice As New Alex.MobileService
            Dim mobileFormIn As New Alex.MobileServiceForm()
            Dim mobileFormOut As New Alex.MobileServiceForm()
            mobileFormIn.methodName = arg1
            mobileFormIn.loginXML = arg2
            mobileFormIn.inputXML = arg3
            mobileservice.SoapVersion = Services.Protocols.SoapProtocolVersion.Soap12
            mobileservice.AllowAutoRedirect = True
            mobileservice.Url = "https://xxx/mobile/MobileService?WSDL"
            Dim Result = mobileservice.mobileService(mobileFormIn)
            mobileFormOut.outputXML = Result.ToString
            lblResults.Text = mobileFormOut.ToString
        End Sub
    End Class

    Wednesday, February 5, 2020 7:43 PM

All replies

  • Hi,
    I haven't called this kind of service yet. For xml web service or WCF, I will generate a proxy class to call the service. Now that you have successfully called the service in SOAPUI, you can try to use the Fiddle capture tool to compare the differences between the two requests to find the problem.
    we can check the format of the SOAP message through the packet capture software. In addition, since the server uses https, have you established a certificate trust relationship between the server-side and the client-side. Please install the server certificate in the Trusted Root Certification Authority certificate store on the client-side.
    Feel free to let me know if there is anything I can help with.
    Best Regards
    Thursday, February 6, 2020 3:27 AM
  • The link below is where you can post about ASP.NET.

    Sunday, February 9, 2020 1:34 AM
  • Thank you
    Wednesday, February 12, 2020 1:49 PM
  • Thank you
    Wednesday, February 12, 2020 1:49 PM