aleczandru
aleczandru

Reputation: 5469

Making a call to a SOAP service with php

Hi I am new to SOAP and I manage to create a webservice with asp.net that contains a method called GetPersons.The service is tested and it works.

My problem is consuming it with php.this is what I hae so far:

 $client = new SoapClient("http://localhost:55400/Convert.asmx?WSDL");
 $client->__soapCall("GetPersons");

This throws an error telling me that __soapCall expects a second arguments parameter but mu GetPersons method has no arguments.

I have also tested to see if PHP gets any methods from the link like this:

 print_r($client->__getFunctions());

This is what I get back:

Array ( [0] => GetPersonsResponse GetPersons(GetPersons $parameters) [1] => GetPersonsResponse GetPersons(GetPersons $parameters) ) 

So how can I make the call to my GetPersons method?

Upvotes: 0

Views: 94

Answers (1)

denormalizer
denormalizer

Reputation: 2214

$url = 'http://localhost:55400/Convert.asmx?WSDL';
$client = new SoapClient($url);

$xmlr = new SimpleXMLElement("<Get></Get>");
$xmlr->addChild('searchtxt', $_GET['searchtxt']);

$params = new stdClass();
$params->xml = $xmlr->asXML();

$result = $client->GetPersons($params);

You need to read the documentation about what parameters to pass.

Related:

Upvotes: 1

Related Questions