1

I am using php soap. I can't get my soap body to include a custom namespace. Here is an example of what I want:

<?xml version='1.0' encoding='UTF8'?><soapenv:Envelope  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <tns:MyCall xmlns:tns="my.sx"><tns:op>getStuff</tns:op><tns:args />
    </tns:MyCall>
  </soapenv:Body>
</soapenv:Envelope>

I can't get the namespace called tns to appear inside the body, or the elements op and args.

Can anyone suggest how this is done?

My code looks like:

$client = CreateSoapClient();

try{
  $result = $client->__soapCall(
   'MyCall',
   array(), // no params
array(
    'uri' => 'urn:Myurn',
    'soapaction' => 'urn:Myurn'
));
?>

1 Answer 1

1

You need to define your namespace in your WSDL. It's probably easiest to just use the Zend WSDL autogenerator, which I believe will let you set the namespace. Let me know if you need more information.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi benjy, Thanks for the reply. I may be very close then, because I have wdsl in xml and also a services.xml Would I create the connection to the server using a local copy of the wdsl by putting the xml in a string ala: <?php $client = new SoapClient($wdsl, array( 'trace'=> $trace_on, 'connection_timeout' => 5, 'soap_version' => SOAP_1_1, 'exceptions' => 0, 'location' => $hostname, 'uri' => 'urn:myURN', 'style' => SOAP_DOCUMENT, 'use' => SOAP_ENCODED )); ?> Or do I put the wdsl file on the server? If so, what to call it? many thanks
I would put the WSDL on the server, and then you can just use the WSDL's URI for $wsdl in your code above. Also, I would strongly recommend setting exceptions to 1 in your options array - makes testing much easier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.