Scenario:
My client is producing based on the WSDL the following SOAP request:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<createFolder xmlns="http://xyz.com/">
<parentId xsi:type="xsd:string">1</parentId>
<folderName xsi:type="xsd:string">Test</folderName>
</createFolder>
</soap:Body>
</soap:Envelope>
This request will fail against CXF. After several investigations I found out that the following manually produced request will work:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xyz="http://xyz.com/">
<soap:Body>
<xyz:createFolder>
<parentId xsi:type="xsd:string">1</parentId>
<folderName xsi:type="xsd:string">Test</folderName>
</xyz:createFolder>
</soap:Body>
</soap:Envelope>
The difference is the namespace definition for the element createFolder
.
My question is: How can I configure SOAPLite to create the working SOAP request?
Or vice versa: How can CXF be configured to accept the SOAP::Lite request style?
Look under ns
. If gives a similarly qualified name for root element of the fragment
Using the following:
SOAP::Lite->new->proxy( 'http://somewhere.com' )
->ns( 'http://xyz.com/', 'xyz' )->createFolder(
SOAP::Data->new( name => 'parentId', value => 1, type => 'xsd:string' )
, SOAP::Data->new( name => 'folderName', value => 'Test' )
);
I got the following:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xyz="http://xyz.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>
<soap:Body>
<xyz:createFolder>
<parentId xsi:type="xsd:string">1</parentId>
<folderName xsi:type="xsd:string">Test</folderName>
</xyz:createFolder>
</soap:Body>
</soap:Envelope>
And I think that's what you want.