Announcement

Collapse
No announcement yet.

How to use SOAP WSDL in Scriptcase 8.1?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use SOAP WSDL in Scriptcase 8.1?

    Recently I updated to SC 8.1

    In 8.1 we can Use SOAP with Macros(sc_webservices)

    Can I have any Tutorials for that ...

    If so I want to add SOAP feature for my existing website. So that I can use it for Mobile applications...

  • #2
    You can use SOAP with standard PHP, check for http://php.net/manual/de/soapclient.soapclient.php
    I have already done that. Since you can place normal php code under a button (for example) it is easy enough.
    And php makes it pretty easy to use soap.

    An example for using for example a peoplesoft service that was made in peplesoft.
    Here I use standard php to send a NR and EMPLID which in my peoplesoft gets read.
    There in peoplesoft I get the record mentioned and in peoplesoft I make the changes to the database where needed.
    When done it gives a reply back, including any failures.

    Code:
    <?php
    /**
     * http://php.net/manual/de/soapclient.soapclient.php
     */
    
    $wsdl="http://127.0.0.1/PSIGW/PeopleSoftServiceListeningConnector/MOD_SCRIPTCASE.1.wsdl";
    
    //$ps=new SoapClient($wsdl,array("exception"=>0,"trace"=>TRUE));    //just catch the error instead of causing an exception 
    try
    {
      $client=new SoapClient($wsdl,array("trace"=>TRUE));    //just catch the error instead of causing an exception 
    
      echo "------------------------------------------\n";
      echo "trying...\n";
      $result = $client->MOD_SCRIPTCASE_MUTFPERS(array('NR' => '999999','EMPLID' => '123456'));  //call the WSDL with 2 parameters NR and EMPLID
      echo "PROCESS done\n";
      
      $LastResponse=$client->__getLastresponse();
      print_r($LastResponse);
      echo "\n";
      //echo $LastResponse."\n";             //string
      //echo gettype($LastResponse)."\n";   //string
      //echo gettype($client) . "\n";       //Object
      //echo get_class($client) . "\n";     //SoapClient
      
      if (is_soap_fault($result)) {
          echo "error soap\n";
          trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
          var_dump($result);
      }else{
        //use simplexml it is easier
        echo "-------------\n";
        $xml=simplexml_load_string($LastResponse);
        if ($xml===false){
          echo "errors in peoplesoft xml handling\n";
          foreach(libxml_get_errors() as $error) {
              echo "\t", $error->message;
          }
          exit;
        }
    
        echo "--XML--\n";
        echo "PeoplesoftReply:-----------\n";
        echo $xml->asXML();
        echo "\n";
          
        echo 'Result='.$xml->children('soapenv',TRUE)->children('ns1',TRUE)->children()->Result . "\n";
        echo 'Status='.$xml->children('soapenv',TRUE)->children('ns1',TRUE)->children()->Status . "\n";
    
        //echo 'XML='.$ch1->children()->asXML() . "\n";
        
        print_r ($xml);
      }
    } catch(SoapFault $f) {
      echo 'Sorry an error was caught executing your request: ' . $f->getMessage();
    }       
    ?>
    SO it all depends on what you want.
    I advise to make a simple standalone php file (as above but then for your wsdl) and get that running first. Then copy the code over to a scriptcase button or library or so.
    Last edited by rr; 07-21-2015, 06:38 AM.

    Comment


    • #3
      RR kinda answered it already.
      But there is a new webservice sample project along with 8.1 that might clarify you a little more.
      The documentation of the new macros should be released soon.
      Regards,
      Cavadinha

      Development Team
      Netmake - IT Solutions

      Comment


      • #4
        Mr Cavadinha is possible paste the webservices of your examples? i can see in your examples about webservices this:
        $resposta = sc_webservice("curl", "http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx/CalcPrecoPrazo", 80, "POST", $parms, array(CURLOPT_RETURNTRANSFER => true), 30, true);

        I would like to know how was design the webservices in your server for CalcPrecoPrazo.

        Comment


        • #5
          Originally posted by alvagar View Post
          Mr Cavadinha is possible paste the webservices of your examples? i can see in your examples about webservices this:
          $resposta = sc_webservice("curl", "http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx/CalcPrecoPrazo", 80, "POST", $parms, array(CURLOPT_RETURNTRANSFER => true), 30, true);

          I would like to know how was design the webservices in your server for CalcPrecoPrazo.
          They are consuming the webservice, didn't developed. If you see, WS is on correios.com.br, a postal service
          /Giuseppe

          Professional Scriptcase Services
          Some Customers opinions

          Comment

          Working...
          X