Newbie: operation?

Help
Emil
2004-10-15
2013-06-06
  • Emil

    Emil - 2004-10-15

    Hi

    I'm very new to soap and nusoap, so I'm sorry if this is off topic, plain dumb or whatever.

    I'm trying to implement a soap client and the info the soap server people has given me is an xml-file I should pass to them and which xml files I might get in return when I pass that file to them.

    But all examples in NuSOAP uses this parameter $operation in the $soapclient->call which seems to be something like the name of what you are trying to do. But I don't have a name, neither do they have any name ($operation) they want to give me. Simply typing '' doesn't help. the server still returns "operation [what I type in $operation] not present."

    The comment to $soapclient->call also seems to be wrong. Atleast the name of the variable. The first parameter is called "@param    string $method SOAP server URL or path" in the comment and $operation in the code.

    I've also tried typing in the URL for the wsdl-server in the $operation parameter like the comment sugests, same error: "operation [what I typed in $operation] not present".

    Please please help me, I'm getting desperate. I need to have this running ASAP.

    Here is my full source, if that helps in any way:

    <?php 
    require_once('./lib/nusoap.php');
    $client = new soapclient('URL_TO_PROVIDER?wsdl', true,'','','','');

    $err = $client->getError();
    if ($err) {
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    }

    //Initialize the params for "inText" The wsdl knows to bind it to the input param (inText) for the SoapServicesTxt method

    $XMLHeader = '<?xml version="1.0" standalone="yes"?>';
    $DetailParams = "$XMLHeader
    <DsERP xmlns=\&quot;http://tempuri.org/DsERP.xsd\&quot;>

        <DtLogin>

            <LoginName>demo</LoginName>

            <Password>demo</Password>

        </DtLogin>

        <DtSO_PONo>

            <OrderNo>2452</OrderNo>

        </DtSO_PONo>

        <DtSO_OrderLine>

            <QuantityOrdered>1</QuantityOrdered>

            <StockCode>lala</StockCode>

        </DtSO_OrderLine>

    </DsERP>";

    $inPutParam = array('inText' => $DetailParams);
    $result = $client->call('ping',$inPutParam);

    if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result);
    echo '</pre>';
    } else {
    $err = $client->getError();
    if ($err) {
    echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
    //echo '<h2>Result</h2><pre>';
    print_r($result);
    //print_r('DID IT ALL');
    echo '</pre>';
    }
    }

    ?>

     
    • <-- R O B-->

      <-- R O B--> - 2004-10-15

      Hi <DtLogin>  is the operation and

      <LoginName>demo</LoginName>

      <Password>demo</Password>

      are the parameters that are passed in the operation.

      <DtSO_PONo>  is a seperate operation - I would think that this has to be called seperately.

      If you are going to send xml rather than an array then you need to look closer at the $client->call parameters. Try something like this:

      //========================================
      $msg = '<DtLogin><LoginName>demo</LoginName><Password>demo</Password></DtLogin>';
      $Method = 'DtLogin';

      $client = new soapclient($wsdl_file, true);

      $err = $client->getError();
      if ($err) {
          echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
      }

      $result = $client->call($Method, $msg, $namespace, '', false, null, 'document', 'literal');

      if ($client->getError() != "") {
          echo "Client Error = " . $client->getError() . "<br>";
      }

      print 'RESULT:<xmp>';
      var_dump($client->document);
      print '</xmp>';

      echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
      echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
      echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

      //==========================================
      Cheers
      Rob C

       
      • Emil

        Emil - 2004-10-16

        Thanks for your help. But it doesn't seem to work.

        I'm panicing a little here :(

        Your codes returns
        Client Error = operation DtLogin not present.
        RESULT:string(0) ""

        [long clip]
        soapclient: got 3 operations from wsdl http://voucherservice.dev2.parttrap.se/VoucherService.asmx?wsdl
        soapclient: call: DtLogin, <DtLogin><LoginName>demo</LoginName><Password>demo</Password></DtLogin>, , , , document, literal; endpointType: wsdl
        soapclient: No data for operation: DtLogin
        soapclient: operation 'DtLogin' not present.
        soapclient: wsdl debug:

        This is how I implemented your code (bascially paste and cut):

        <?php 
        require_once('./lib/nusoap.php');
        //$client = new soapclient('file:./Order.xml', true,'','','','');
        $wsdl_file = 'http://voucherservice.dev2.parttrap.se/VoucherService.asmx?wsdl';

        //========================================
        $msg = '<DtLogin><LoginName>demo</LoginName><Password>demo</Password></DtLogin>';
        $Method = 'DtLogin';

        $client = new soapclient($wsdl_file, true);

        $err = $client->getError();
        if ($err) {
            echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
        }

        $result = $client->call($Method, $msg, $namespace, '', false, null, 'document','literal');

        if ($client->getError() != "") {
            echo "Client Error = " . $client->getError() . "<br>";
        }

        print 'RESULT:<xmp>';
        var_dump($client->document);
        print '</xmp>';

        echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES)
        . '</pre>';
        echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES)
        . '</pre>';
        echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES)
        . '</pre>';

        //==========================================
        ?>

         
        • Emil

          Emil - 2004-10-16

          Btw

          this: <?xml version="1.0" standalone="yes"?>
          and this: <DsERP xmlns=\&quot;http://tempuri.org/DsERP.xsd\&quot;>

          aren't part of your code. what's DsERP about if DtLogin is the operation?

           

Log in to post a comment.