Question Web Reference call not sending paramater

RoboticBD

New member
Joined
Apr 1, 2015
Messages
3
Programming Experience
10+
Hello All,

I am working with a customer where I am connected to their page and they provided me their wsdl. I used Web Reference using their wsdl. I have one function that I call and it sends me back the information with no problem. If I do another call where I provide a parameter to send out, I get an "Internal Error (from client)" back.

Now when I use SOAPUI, I do not get an error and I do get the correct information back.

Here is my code

VB.NET:
Dim myService As New wbsMyService.MyService
   Dim cert As X509Certificate2 = New X509Certificate2(Application.StartupPath & "\MyCert.cer", "MyPassword")

    Public Function wbs_Initialze() As Boolean
        Dim boolReturn As Boolean = False
        Try
            myService.SoapVersion = Web.Services.Protocols.SoapProtocolVersion.Soap11
            myService.PreAuthenticate = True
            myService.ClientCertificates.Add(cert)
            myService.Url = "https://customersendpoint"
            myService.Timeout = 60000
            myService.UserAgent = "Apache-HttpClient/4.1.1"
            myService.AllowAutoRedirect = True
         
            ' myService.Discover()
            boolReturn = True
        Catch ew As SoapException
            MessageBox.Show(ew.Message)
        Catch ex As Exception
            comVariabes.strTestTheory = ex.Message
            boolReturn = False
        End Try
        Return boolReturn

  Public Function wbs_GetMyNamesNames() As String
        'THIS WORKS
        Dim strResult As String

        Try
            strResult = myService.GetMyNamesNames()
            If strResult Is Nothing Then
                strResult = ""
            ElseIf strResult = "" Then
                strResult = ""

            End If
        Catch ex As WebException
            strResult = ex.Message
        Catch ew As SoapHeaderException
            strResult = ew.Message
        End Try
        Return strResult

    End Function

   Public Function wbs_GetMyFunction(strUserName As String) As String
       'THIS DOES NOT WORK
        Dim strResult As String
        Dim str As String = myService.ConnectionGroupName
        Try
            strResult = myService.GetMyFunction(strUserName.Trim)
            If strResult Is Nothing Then
                strResult = "NOTHING"
            End If
            'Catch ex As SoapException
            '    strResult = ex.Message
        Catch ew As SoapHeaderException
            strResult = ew.Message
        End Try
        Return strResult

And here is a sample of their wsdl file. I did have to replace certain words with generic words for certain security reasons

VB.NET:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd" xmlns:tns="MyData/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="MyData/">
    <wsdl:types>
        <xsd:schema targetNamespace="MyData/">
            <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
            <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
        
            <xsd:simpleType name="Username_Type">
                <xsd:restriction base="xsd:string">
                    <xsd:pattern value="[a-zA-Z0-9][\p{P}]{0,25}"/>
                </xsd:restriction>
            </xsd:simpleType>

        </xsd:schema>
    </wsdl:types>

    <message name="GetMyNamesNamesRequest"/>
    <message name="GetMyNamesNamesResponse">
        <part name="return" type="xsd:string"/>
    </message>
  <message name="GetMyFunctionRequest">
    <part name="Username" type="tns:Username_Type"/>
  </message>
  <message name="GetMyFunctionResponse">
    <part name="return" type="xsd:string"/>
  </message>

    <portType name="MyPortType">
            <operation name="GetMyNamesNames">
            <documentation>Retrieves all program names</documentation>
            <input message="tns:GetMyNamesNamesRequest"/>
            <output message="tns:GetMyNamesNamesResponse"/>
        </operation>
        <operation name="GetMyFunction">
            <documentation>Retrieves email address from username</documentation>
            <input message="tns:GetMyFunctionRequest"/>
            <output message="tns:GetMyFunctionResponse"/>
        </operation>
    </portType>
  
    <binding name="MyBinding" type="tns:MyPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    
    
        <operation name="GetMyNamesNames">
            <soap:operation soapAction="GetMyNamesNames" style="rpc"/>
            <input>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://MyData"/>
            </input>
            <output>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://MyData"/>
            </output>
        </operation>
    
    
        <operation name="GetMyFunction">
            <soap:operation soapAction="GetMyFunction" style="rpc"/>
            <input>
                <soap:body use="encoded"  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  namespace="http://MyData"/>
      </input>
            <output>
                <soap:body use="encoded"  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://MyData"/>
            </output>
        </operation>
    
    </binding>
    <service name="MyService">
        <port name="MyPort" binding="tns:MyBinding">
            <soap:address location="https://MyData/Mydata"/>
        </port>
    </service>
</definitions>
 
Top Bottom