Showing posts with label portName. Show all posts
Showing posts with label portName. Show all posts

Choose among multiple services, multiple ports

Thursday, June 19, 2008

If your wsdl has multiple services and multiple ports, You can tell your PHP client to use a preferred service and port by setting "serviceName" and "portName" option in the WSClient.

For an example if you take wsdl1.1 with multiple services and ports like this,

<wsdl:service name=\"Adder1\">
<wsdl:port name=\"SOAP11port_http\" binding=\"ns0:AdderSOAP11Binding\">

<soap:address location=\"http://localhost:8080/axis2/services/Adder1\"/>
</wsdl:port>
<wsdl:port name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\">

<soap12:address location=\"http://localhost:8080/axis2/services/Adder1\"/>
</wsdl:port>
<wsdl:service/>
<wsdl:service name=\"Adder2\">

<wsdl:port name=\"SOAP11port_http\" binding=\"ns0:AdderSOAP11Binding\">
<soap:address location=\"http://localhost:8080/axis2/services/Adder2\"/>

</wsdl:port>
<wsdl:port name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\">
<soap12:address location=\"http://localhost:8080/axis2/services/Adder2\"/>

</wsdl:port>
<wsdl:service/>


You can select the Adder2 service with SOAP12port_http with the following optional arguments to the getProxy method.

$client = new WSClient(array(\"wsdl\" => \"your_wsdl\"));

$proxy =
$client->getProxy(\"Adder2\", \"SOAP12Port_http\");



This can be represented in wsdl2 as following,

<service name=\"Adder1\" interface=\"ns0:AdderPortType\">
<endpoint name=\"SOAP11port_http\" binding=\"ns0:SOAP11Binding\" address=\"http://localhost:8080/axis2/services/Adder1\"/>

<endpoint name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\" address=\"http://localhost:8080/axis2/services/Adder1\"/>
</service>

<service name=\"Adder2\" interface=\"ns0:AdderPortType\">
<endpoint name=\"SOAP11port_http\" binding=\"ns0:SOAP11Binding\" address=\"http://localhost:8080/axis2/services/Adder2\"/>

<endpoint name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\" address=\"http://localhost:8080/axis2/services/Adder2\"/>
</service>

Note that here portName you provided is considered as the endpoint name under the selected service.

When you don't provide either serviceName and the portName, wsf/php will pick the first serviceName and portName listed in the wsdl.

Although multiple services in the same wsdl is very rare, multiple ports /endpoints in the same service is very common. Specially when you support multiple versions of SOAP, addressing, or even completely different policies for the interface you will surely be having multiple ports.