1

I'm trying to create a SOAP message using PHP's DOMDocument class. I have a raw XML example to work from, and need to start off with an envelope that matches the following:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://example.url/v1">

To create this, I have been trying:

$xml = new DOMDocument('1.0');
$env = $xml->createElementNS('http://schemas.xmlsoap.org/soap/envelope', 'soapenv:Envelope');
$env->setAttributeNS('http://www.w3.org/2000/xmlns', 'xmlns:v1', 'http://example.url/v1');

At this point (using the PHP console), I get an uncaught DOMException with the message "Namespace Error".

I'm very new to crafting SOAP requests by hand, so I've no doubt I'm misunderstanding something basic. Could anyone point me in the right direction?

Cheers

1 Answer 1

0

Fixed, with a wonderfully simply answer.

Turns out that http://www.w3.org/2000/xmlns/ requires that trailing slash.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.