Passing class instance parameter

Help
Ale
2011-02-14
2013-06-06
  • Ale

    Ale - 2011-02-14

    I have to call an operation declared in a webservice. This operation has the following declaration:
    OUTPUTMSG Operation(INPUTMSG $INPUT-MSG)

    I've the following code in my webservice client:

    class INPUTMSG
    {
    public $in_ll;
    }

    $input = new INPUTMSG();
    $input->in_ll = '59';

    require_once('lib/nusoap.php');
    $cliente = new nusoap_client('http://server:port/Service?wsdl', 'wsdl');

    $aRespuesta=$cliente->call('Operation', array('input' => $input);

    The question is: Is the "call" method called properly?? I'm not getting any answer from the "call"

    Thanks

     
  • Scott Nichol

    Scott Nichol - 2011-02-14

    When you are first creating a SOAP client and may need to check for errors and debug, it is recommended you use code like the following

    $result = $soapclient->call('Operation', array('input' => $Input));
    if ($soapclient->fault) {
        echo '<h2>Fault</h2><pre>';
        print_r($result);
        echo '</pre>';
    } else {
        $err = $soapclient->getError();
        if ($err) {
            echo '<h2>Error</h2><pre>' . $err . '</pre>';
        } else {
            echo '<h2>Result</h2><pre>';
            print_r($result);
            echo '</pre>';
        }
    }
    echo '<h2>Request</h2><pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Response</h2><pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
    echo '<h2>Debug</h2><pre>' . htmlspecialchars($soapclient->debug_str, ENT_QUOTES) . '</pre>';

    This code checks for SOAP Faults and local errors, prints the result, and prints SOAP request, SOAP response and all debugging.  Thus when you believe that you are "not getting any answer from the call" you will have information provided about exactly what your code is doing.

    With the code you give, my question would be whether the WSDL at 'http://server:port/Service?wsdl' really calls the operation 'Operation' and the input parameter 'input'.  Both of these values are case sensitive.  Also, service documentation sometimes specifies names for parameters that are not the names the WSDL specifies.

     
  • Ale

    Ale - 2011-02-15

    snichol, thanks for the response.
    The code checks for SOAP that you say i've allready included in my code (i allways do it).
    Trying to solve my problem, i'd used SoapClient native PHP extension and i could get a response. Next is the result of a __getFunctions call: "array(1) { =>  string(51) "OUTPUTMSG Operation(INPUTMSG $INPUT-MSGPart)" } "
    However, i'd like to get a response using NuSOAP.
    Could you help me? Thanks in advance…

     
  • Scott Nichol

    Scott Nichol - 2011-02-15

    If you can post the WSDL or URL to the WSDL or the debug output from your NuSOAP client, I can help.  Usually no response means there is something incomplete in the request.  There are multiple reasons that may happen, but the most common is that the name of an element or message part in the WSDL is not exactly matched by the PHP code.  If the same code works with the PHP SOAP extension, perhaps the extension is more forgiving about this.

     
  • Ale

    Ale - 2011-02-16

    <wsdl:definitions name="IMSPHBK" targetNamespace="file://target.files">

    <wsdl:types>

    <schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.IMSPHBKI.com/schemas/IMSPHBKIInterface">

    <complexType name="INPUTMSG">

    <sequence>

    <element form="qualified" name="in_ll">

    <simpleType>

    <restriction base="short">
    <minInclusive value="-999"/>
    <maxInclusive value="999"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_zz">

    <simpleType>

    <restriction base="short">
    <minInclusive value="-999"/>
    <maxInclusive value="999"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_trcd">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_cmd">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="8"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_name1">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_name2">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_extn">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="in_zip">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="7"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>
    </sequence>
    </complexType>

    <element name="INPUTMSG" type="cbl:INPUTMSG">

    <annotation>
    <documentation source="com.ibm.etools.xmlent.batch">9.0.400.V20090801_0720</documentation>
    </annotation>
    </element>
    </schema>

    <schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.IMSPHBKO.com/schemas/IMSPHBKOInterface">

    <complexType name="OUTPUTMSG">

    <sequence>

    <element form="qualified" name="out_ll">

    <simpleType>

    <restriction base="short">
    <minInclusive value="-999"/>
    <maxInclusive value="999"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_zz">

    <simpleType>

    <restriction base="short">
    <minInclusive value="-999"/>
    <maxInclusive value="999"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_msg">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="40"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_cmd">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="8"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_name1">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_name2">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_extn">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="10"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_zip">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="7"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>

    <element form="qualified" name="out_segno">

    <annotation>

    <appinfo source="http://www.wsadie.com/appinfo">
    <initialValue kind="SPACE"/>
    </appinfo>
    </annotation>

    <simpleType>

    <restriction base="string">
    <maxLength value="4"/>
    <whiteSpace value="collapse"/>
    </restriction>
    </simpleType>
    </element>
    </sequence>
    </complexType>

    <element name="OUTPUTMSG" type="cbl:OUTPUTMSG">

    <annotation>
    <documentation source="com.ibm.etools.xmlent.batch">9.0.400.V20090801_0720</documentation>
    </annotation>
    </element>
    </schema>
    </wsdl:types>

    <wsdl:message name="IMSPHBKOperationRequest">
    <wsdl:part name="INPUT-MSGPart" element="xsd1:INPUTMSG">
        </wsdl:part>
    </wsdl:message>

    <wsdl:message name="IMSPHBKOperationResponse">
    <wsdl:part name="OUTPUT-MSGPart" element="xsd2:OUTPUTMSG">
        </wsdl:part>
    </wsdl:message>

    <wsdl:portType name="IMSPHBKPortType">

    <wsdl:operation name="IMSPHBKOperation">
    <wsdl:input name="IMSPHBKOperationRequest" message="tns:IMSPHBKOperationRequest">
        </wsdl:input>
    <wsdl:output name="IMSPHBKOperationResponse" message="tns:IMSPHBKOperationResponse">
        </wsdl:output>
    </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="IMSPHBKBinding" type="tns:IMSPHBKPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

    <wsdl:operation name="IMSPHBKOperation">
    <soap:operation soapAction="urn:IMSPHBK" style="document"/>

    <wsdl:input name="IMSPHBKOperationRequest">
    <soap:body parts="INPUT-MSGPart" use="literal"/>
    </wsdl:input>

    <wsdl:output name="IMSPHBKOperationResponse">
    <soap:body parts="OUTPUT-MSGPart" use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="IMSPHBKService">

    <wsdl:port name="IMSPHBKPort" binding="tns:IMSPHBKBinding">
    <soap:address location="http://10.1.4.122:8080/imssoap/services/IMSPHBKService.IMSPHBKPort/"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

     
  • Scott Nichol

    Scott Nichol - 2011-02-16

    NuSOAP uses the message part names as the parameter names for method calls.  Therefore, I believe it expects your call to look like this:

    $aRespuesta=$cliente->call('IMSPHBKOperation', array('INPUT-MSGPart' => $input));

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks