0

I received a manual to internal SOAP interface of my partner. It says:

MyPARTNER web services are provided in the form of a SOAP interface. The service is available in this URL: https://justsomeurl.com:435/soap

then some bla bla about authorization etc. and then a part about Accessible Methods:

pull()

The PULL method is used for pulling data from the database. The method receives a unique data based parameter under an internal name requestXML. This parameter contains data in a structured XML format.

String pull(String requestXML)

The XML contains data required to make the request, and the response data is sent back.

then some other methods, error codes, it's not important here... The problem is that I'm totally unexperienced in SOAP so I don't know how to use this interface via PHP. I've tried to find some examples, tutorials and I am now little bit more informed about SOAP and its functionality but still haven't found any advice about how to use interface like this...

thanx for any help

1 Answer 1

1

Php comes with PHP SOAP libraries, that usually are included and enabled after a common php installation.

Yuo are asked to biuld the client part of the webservice pattern. Your partner should provide you the .wsdl of the web service. The wsdl describes the avialble method, the parameters they need and what they return.

Tipically parameters and return values are array structures

This could be a skeleton for your code:

 //build a client for the service
 $client = new SoapClient("partner.wsdl");

 //$client is now a sort of object where you can call functions
 //prepare the xml parameter
 $requestXML = array("parameter" => "<xml>Hello</xml>");

 //call the pull function this is like 
 $result = $client->__soapCall("pull", $requestXML );

 //print the value returned by the web service
 print_r($result);

Here follows a non-wsdl example First the location paramater is the address the SOAP request will be sent to. The uri parameter is the target namespace of the SOAP service. This is related to xml namespaces.

A sample code for you could be: //for URI specification you should watch your partners documentation. maybe also a fake uri (like mine) could work //build a client for the service $client = new SoapClient(null, array( 'location' => "https://justsomeurl.com:435/soap", 'uri' => "urn:WebServices", 'trace' => 1 ));

 // Once built a non-wsdl web service works as a wsdl one
 //$client is now a sort of object where you can call functions
 //prepare the xml parameter
 $requestXML = array("parameter" => "<xml>Hello</xml>");

 //call the pull function this is like 
 $result = $client->__soapCall("pull", $requestXML );

 //print the value returned by the web service
 print_r($result);

Here a useful link: http://www.herongyang.com/PHP/SOAP-Use-SOAP-Extension-in-non-WSDL-Mode.html

Sign up to request clarification or add additional context in comments.

7 Comments

yes, I've read about this library, but is it definitely necessary to have '.wsdl'? because all I have is URL I've mentioned above...is there any way to use SoapClient without '.wsdl' file?
OK, thanx for link, it's bit clearer to me...however (and feel free to call me a lame) it's still not clear to me what should I set to parameters 'location' and 'uri' of the options array of SoapClient constructor. Could you please show me some concrete example using my URL? I'd be very grateful
Well...I tried it your way, and almost hundred another ways, always with the same result - Fatal error: Uncaught SoapFault exception: [Receiver] Unknown error in D:\...\index.php:127 Stack trace: #0 D:\...\index.php(127): SoapClient->__soapCall('pull', Array) #1 {main} thrown in D:\...\index.php on line 127 ...I browsed many forums, but no result... I'm really frustrated of all this because I'm not sure if there somthing wrong on my side or on server side or on my partner's side...thank you for patience
I've also tried to run script from tutorial from your last link, but theres an fatal error too: Uncaught SoapFault exception: [HTTP] Could not connect to host in D:\... Stack trace: #0 [internal function]: SoapClient->__doRequest('__soapCall('getTemp', Array) #2 {main} thrown in D:\...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.