Forum Moderators: coopster

Message Too Old, No Replies

PHP and SOAP/wsdl

Need some assistance with this

         

mousico

8:12 am on Jul 21, 2011 (gmt 0)

10+ Year Member



I am more than comfortable with PHP and OOP but I have a task to complete using WSDL and SOAP and I've never used these technologies before so I need some guidance if there is anyone out there that can help. I downloaded and installed XMLspy and I created a new SOAP request using the url I was given by the data provider. This resulted in the following XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.o… xmlns:SOAP-ENC="http://schemas.xmlsoap.o… xmlns:xsi="http://www.w3.org/2001/XMLSch… xmlns:xsd="http://www.w3.org/2001/XMLSch…
<SOAP-ENV:Body>
<m:EnquiryRequest xmlns:m="http://webservices.hpi.co.uk/Co…
<m:Authentication>
<m:ServiceVersion>
<m:MajorVersion>0</m:MajorVersion…
<m:MinorVersion>0</m:MinorVersion…
</m:ServiceVersion>
<m:SubscriberDetails>
<m:CustomerCode>a</m:CustomerCode…
<m:Initials>aa</m:Initials>
<m:Password>a</m:Password>
</m:SubscriberDetails>
</m:Authentication>
<m:Request>
<m:Asset>
<m:Vrm></m:Vrm>
<m:Vin></m:Vin>
<m:Mileage>0</m:Mileage>
<m:Reference>aaaaaaaaaa</m:Refere…
</m:Asset>
<m:PrimaryProduct>
<m:Code>String</m:Code>
</m:PrimaryProduct>
</m:Request>
</m:EnquiryRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I have the account details necessary to fill the blanks above but how do I send a query to this data provider and what form will I receive the response in? A simple example would be really helpful pleeease.

Thanks in advance.

lostdreamer

12:45 pm on Jul 28, 2011 (gmt 0)

10+ Year Member



PHP + SOAP is pretty easy actually.
You don't even have to worry about the XML part of it.

Check if your installation of PHP allready has SOAP installed.
If so, follow the following example:

$strUrl = "http://webservices.hpi.co.uk/Co...";
# define namespace
$namespace="http://tempuri.org/";
# create SOAP object
$client = new soapclient($strUrl);
# optional parameters
$params = array(
'param_name_1'=> $val_1,
'param_name_2'=> $val_2
);
$result = $client->call('SomeFunction', array('parameters' => $params));
var_dump($result);

And there you'll have the output from your SOAP service

If you dont have SOAP installed, you can download a class called NUSOAP which will work allmost the same.


Good luck

penders

3:01 pm on Jul 28, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



$result = $client->call('SomeFunction', array('parameters' => $params));


Shouldn't call() be __call() ?

The __call() [ch2.php.net] method is apparently deprecated in favour of __soapCall() [ch2.php.net]

lostdreamer

3:13 pm on Jul 28, 2011 (gmt 0)

10+ Year Member



I've allways been able to do simply
$client->call("SomeFunction")
or $client->someFunction()

But it might depend on the PHP version.