0

i'm developing a website in PHP and want to integrate it with SAP B1, my question is can anyone show me how to connect to web services(B1WS) with DI Server using PHP?

Thank you

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Schadrack Rurangwa
  • 413
  • 12
  • 28

1 Answers1

0

I don't know B1WS but i can say you how to connect a web service, you must use the soap object in PHP, or better i use that... usually a connection, where pathWsdl is the link of the wsdl inside the project and the $url is the the url of the webService...Once you are connected every wsdl has some operations that can be called, and every operation usually need some parameters in input and gives an output....here the connection:

    $connessione = new SoapClient($pathWsdl,array (
            "login" => $user,
            'password' => $pass,
            "trace" => true,
            "connection_timeout"=> 15,
    ) );
    $connessione ->__setLocation($url);

To call the operation once you are connected

    //chiamiamo l'operazione e gli passiamo i parametri
    $rispostaRichiestaOperazione = $connessione->__soapCall($operazioneRichiesta, array(
            "parametriOperation" => $parametriOperation
    ));

Where operationRichiesta is the operation that can be call inside the wsdl and $parametriOperation is usually an array of parameters that you must define reading the wsdl for that operation that you are calling, every wsdl can have differents operations with differents input params, the keys of the array has the same name of the name attributes inside the wsdl, and you must see if you need an array or a simple string from the wsdl, for sure you must have the wsdl description and code to can do the right call because if you wrong to write a name(key of array) the call goes in error. $rispostaRichiestaOperazione is usually an stdClass that you can convert in array... Hope this help a little...

  • Hi Spizzi, I tried to use your codes but I get error message Fatal error: Uncaught Error: Call to undefined method soapclient::__setLocation() in C:\xampp\htdocs..... How can I difine that method? Please anyone can help me – Schadrack Rurangwa May 09 '18 at 13:29
  • No setLocation is a method of the soap object....it's impossible that goes in error use the correct url and wsdl path and look at this var_dump is there setLocation? print'
    ';var_dump(get_class_methods('SoapClient'));print'
    '; look also at the manual: http://php.net/manual/en/soapclient.setlocation.php
    –  May 09 '18 at 13:54
  • Ahhh but wait you are in xampp local....this is the problem....soapclient is not able in your php.ini in xampp...lokk here: https://stackoverflow.com/questions/11391442/fatal-error-class-soapclient-not-found –  May 09 '18 at 13:55