php - How to add the namespace to all elements that get returned WSDL / SOAP -
i'm new soap , wsdl world. have do, make sure namespace in return-element?
<?xml version="1.0" encoding="utf-8"?> <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://someurl.com"> <soap-env:body> <ns1:sayhelloresponse> <return>say hello kelvin</return> </ns1:sayhelloresponse> </soap-env:body> </soap-env:envelope>
what want is:
<ns1:sayhelloresponse> <ns1:return>say hello kelvin</ns1:return> </ns1:sayhelloresponse>
i'm using php , zend framework. wsdl gets generated zend_soap_autodiscovery. shouldn't barrier though, because modify output of anyways.
thanks help.
after taking break while, approached problem once again. time though, stumbled upon nice article (credits former co-worker mike). if attribute elementformdefault isn't declared in schema tag, unqualified assumed value. giving value "qualified" following happen:
but if add elementformdefault="qualified" of schemas in document/literal wrapped wsdl, elements in messages qualified parent's namespace.
in general, not want use elementformdefault="qualified" because bloats messages, year or more ago there interoperability issues between various vendors, , setting attribute fixed problems.
even though wasn't using document/literal, wanted try out. added attribute schema tag , made request different call. here's response got:
<ns1:getuserresponse> <return> <ns1:firstname>first</ns1:firstname> <ns1:lastname>last</ns1:lastname> </return> </ns1:getuserresponse>
as can see, child elements of "return"-element got namespace prefixed. @ point got excited, because got closer wanted be. unfortunately, return element didn't have namespace prefixed. tried earlier call (see question post) again, response same before.
i couldn't spend more time on issue. prototype after all. that's why decided hook zend_soap_server's handle function, modify response before outputting it.
class custom_soap_server extends zend_soap_server { public function __construct($wsdl = null, array $options = null) { parent::__construct($wsdl, $options); // response of handle returned $this->setreturnresponse(true); } public function handle($request = null) { $response = parent::handle($request); echo str_replace(array('<return>', '</return>'), array('<ns1:return>', '</ns1:return>'), $response); return; } }
to honest, it's nasty hack. i'm assuming there's 1 namespace. replace function written better. prototype after , first thought make work.
after using new custom class instead of zend_soap_server, of return elements had ns1 prefixed them.
Comments
Post a Comment