I’m interfacing to a WCF web service that exposes its method using SOAP, using PHP 5.3.10. I’m hoping to be able to use the SoapClient, but I’m having trouble formulating the requests properly.
The WSDL appears to be 1.0 ( xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/ in the wsdl:definitions tag).
Each operation in the WSDL is defined similar to this:
<wsdl:operation name="GetPortfolios">
<soap:operation soapAction="urn:IPortfolio/GetPortfolios" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
I’d like to create the request for the body as an array, so that the soap body ends up looking something like this:
<GetPortfolios>
<Portfolio>*con*</Portfolio>
<Token>1234</Token>
</GetPortfolios>
Can this be done with the PHP 5.3.10 SoapClient? (and an example please). I would prefer if the call the to SoapClient instanced called __soapCall().
Update:
Above the bindings is an import for another WSDL.
The original WSDL is https://clienttest.praemium.biz/praemiumclientwebservice/PortfolioService.svc?wsdl.
The import looks like: <wsdl:import namespace="" location="https://clienttest.praemium.biz/PraemiumClientWebService/PortfolioService.svc?wsdl=wsdl0"/>.
And that provider further information about the requests and responses, at the operation level, and also does another import:
<xsd:schema targetNamespace="/Imports">
<xsd:import schemaLocation="https://clienttest.praemium.biz/PraemiumClientWebService/PortfolioService.svc?xsd=xsd0"/>
</xsd:schema>
It is this import that details the actual elements expected in the requests, and the elements to expect in the responses.
As an aside, can the PHP SoapClient deal with chained imports like this?
I’ve ended up having to skip using the WSDL, and specify the location, uri, style and use as arguments to the SoapClient constructor. style is set to SOAP_DOCUMENT, and use is set to SOAP_LITERAL.
When calling __soapCall(), the second argument is a SoapVar wrapping raw XML, in an array (i.e.
$data = array(new SoapVar($xmlString, XSD_ANYXML));). If you’ve generated your XML using SimpleXML::asXML(), be sure to strip the<?xml version="1.0" encoding="UTF-8"?>header off first.Also, because I’m talking to a WCF web service exposed as SOAP (i.e. .NET SOAP), the SOAPAction requires a forward slash separator, instead of the default PHP hash. To do this, pass an array with a ‘soapaction’ entry being the uri + forward slash + operation (i.e.
$uri.'/'.$operation), as the third argument to the __soapCall().