I have following soap string.
$str = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">';
$str .= '<soapenv:Header/>';
$str .= '<soapenv:Body>';
$str .= '<Username>uname1</Username>';
$str .= '<Password>upassword1</Password>';
$str .= '<RequestType>GetDiamonds</RequestType>';
$str .= '<ClientId>51</ClientId>';
$str .= '<MySoapReq>';
$str .= '<Params>';
$str .= '<Diamond_ID>%18112%</Diamond_ID>';
$str .= '<Diamond_ID>%1625%</Diamond_ID>';
$str .= '<Diamond_ID>%18625%</Diamond_ID>';
$str .= '</Params>';
$str .= '</MySoapReq>';
$str .= '</soapenv:Body>';
$str .= '</soapenv:Envelope>';
I am trying to call it in following way but not getting how I will pass above string to soap request.
$client = new SoapClient(null, array('location' => 'http://localhost:8080/testsoap',
'uri'=>'http://localhost:8080/testsoap'
));
I have also tried giving username and password here but it did not work then I tried following.
$return = $client->__soapCall("GetDiamonds",
array(new SoapParam($str))
);
Any suggestions how I can pass above string in soap request and get response? Am I doing in a right way or there should be other method for this?
The best and fast way to pass the parameters to the Soap Web Service is to use a WSDL to php generator as you won't wonder how to construct the request.
Try the PackageGenerator project and you'll see it's easy to construct the request (without making any error unless you're doing it purposely ;)). In addition, the received response is easily handled. Each part is an object.