Calling webservice with array of complex type

Help
Yagg
2010-08-24
2013-06-06
  • Yagg

    Yagg - 2010-08-24

    How can i call dotnet webservice method with array of complex type parameter?

    My code:

    $params = array(
                            'ID' => '0', 
                            'Parameters' => array(
                        'ProcedureParameter' => array( // i want to send to webservice dublicated array key
                            'ID' => "DateFrom", 
                            'Value' => "01/01/1980"
                            ),
                        'ProcedureParameter' => array( // i want to send to webservice dublicated array key
                            'ID' => "DateTo", 
                            'Value' => "01/01/2011"
                            )
                         )
                    );
    $resultset = $client->call('GenerateRecordSet', 
        array('secUser' => $bssuser,
                'aExportType' => 'JobBoard',
                'aParameterSets' => array('ProcedureParameterSet' => $params)
            )
        );
    

    ASP.Net webservice expects the following xml in input:

    SOAPAction: "http://tempuri.org/GenerateRecordSet"
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <GenerateRecordSet xmlns="http://tempuri.org/">
          <secUser>
            <Alias>string</Alias>
            <SecurityString>string</SecurityString>
            <UserID>int</UserID>
            <GroupID>int</GroupID>
            <RegionID>int</RegionID>
            <IntegrationID>int</IntegrationID>
          </secUser>
          <aExportType>string</aExportType>
          <aParameterSets>
    [b]        <ProcedureParameterSet>[/b]
              <ID>int</ID>
              <Parameters>
    [b]            <ProcedureParameter xsi:nil="true" />[/b]
    [b]            <ProcedureParameter xsi:nil="true" />[/b]
              </Parameters>
            </ProcedureParameterSet>
    [b]        <ProcedureParameterSet>[/b]
              <ID>int</ID>
              <Parameters>
    [b]            <ProcedureParameter xsi:nil="true" />[/b]
    [b]            <ProcedureParameter xsi:nil="true" />[/b]
              </Parameters>
            </ProcedureParameterSet>
          </aParameterSets>
        </GenerateRecordSet>
      </soap:Body>
    </soap:Envelope>
    

    But nusoap generate this:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope 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:ns5756="http://tempuri.org">
    <SOAP-ENV:Body>
        <GenerateRecordSet xmlns="http://tempuri.org/">
            <secUser>
                <Alias>fhcs</Alias>
                <SecurityString>cB7J/mh/6CI2PBdy3suuDA==</SecurityString>
                <UserID>9326</UserID>
                <GroupID>5984</GroupID>
                <RegionID>-1</RegionID>
                <IntegrationID>-1</IntegrationID>
            </secUser>
            <aExportType>JobBoard</aExportType>
            <aParameterSets>
                <ProcedureParameterSet>
                    <ID>0</ID>
                    <Parameters>
                        <ProcedureParameter ID="DateTo" Value="01/01/2011">
                        </ProcedureParameter>
                    </Parameters>
                </ProcedureParameterSet>
            </aParameterSets>
        </GenerateRecordSet>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    There is the part of wsdl for my method:

          <s:element name="GenerateRecordSet">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="secUser" type="tns:BSSSecureUser" />
                <s:element minOccurs="0" maxOccurs="1" name="aExportType" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="aParameterSets" type="tns:ArrayOfProcedureParameterSet" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:complexType name="ArrayOfProcedureParameterSet">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="unbounded" name="ProcedureParameterSet" nillable="true" type="tns:ProcedureParameterSet" />
            </s:sequence>
          </s:complexType>
          <s:complexType name="ProcedureParameterSet">
            <s:sequence>
              <s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int" />
              <s:element minOccurs="0" maxOccurs="1" name="Parameters" type="tns:ArrayOfProcedureParameter" />
            </s:sequence>
          </s:complexType>
          <s:complexType name="ArrayOfProcedureParameter">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="unbounded" name="ProcedureParameter" nillable="true" type="tns:ProcedureParameter" />
            </s:sequence>
          </s:complexType>
          <s:complexType name="ProcedureParameter">
            <s:attribute name="ID" type="s:string" />
            <s:attribute name="Value" type="s:string" />
          </s:complexType>
    
     
  • Oz030

    Oz030 - 2010-08-30

    First of all you should set the nameSpace property in your .Net application. To do so go to your Web.config and add: "bindingNamespace="http://www.yourdomain.com/" or if local : "bindingNamespace="http://localhost/"  as attribute in the <endpoint> element like this:

     <endpoint address="" binding="basicHttpBinding" contract="YourNameSpace.IYourContract" bindingConfiguration="YourBasicHTTPBinding" bindingNamespace="http://www.yourdomain.com/" >
    

    I doubt that you host "http://tempuri.org/" and that there is a method "GenerateRecordSet".

     
  • Yagg

    Yagg - 2010-09-09

    I tried this, but it does not help. The problem is not in a namespace. This problem may very well be a limitation of nusoap to pass multiple parameters with identical names(ProcedureParameter in my example).
    The similar example with SOAP extension is working properly:

    $params = array(
                            'ID' => '0', 
                            'Parameters' => array( // data filter
                                array('ID' => "State", 'Value' => "NY"),
                                array('ID' => "DateFrom", 'Value' => "04/01/2010"),
                        array('ID' => "DateTo", 'Value' => "05/01/2010"),
                        array('ID' => 'OrderBy','Value' => 'Id')
                            ) 
                    );
    $result = $client->GenerateRecordSet( 
        array('secUser' => $bssuser,
                'aExportType' => 'JobBoard',
                'aParameterSets' => array('ProcedureParameterSet' => $params)
            )
        );
    

    But my hosting plan does not include the SOAP extension so I am using nusoap.

    If I do not specify the names of the parameters(as in example with SOAP extension), then nusoap not generate the correct request.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks