SOAP re-declaring qname inside body - web-services

I have a SOAP request of this form:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:myqname="http://example.com/hello"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<myqname:MyRequest xmlns:myqname="http://example.com/hello">
...
</myqname:MyRequest>
</soapenv:Body>
</soapenv:Envelope>
If I ask SOAPUI to "Format XML" this request,
it removes the second declaration of myqname, so I get this:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:myqname="http://example.com/hello"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<myqname:MyRequest>
...
</myqname:MyRequest>
</soapenv:Body>
</soapenv:Envelope>
The original request works fine,
but the Application Servers fails with the modified request with this error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'myqname:MyRequest' as a QName: the prefix 'myqname' is not declared.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
According to the web services specification,
is it mandatory for the qname to be re-declared inside the soapenv:Body node?
Is this a SOAPUI bug, or an Application Server bug? or a misunderstanding from my part?
SOAPUI 4.0.1, WebLogic Server Version: 10.3.2.0
Edit: ups, even if using WebLogic application server, I was using the CXF web services framework. I posted the issue there. issues.apache.org/jira/browse/CXF-4026
So: SOAPUI 4.0.1, CXF 2.5.0

I'd describe it as a bug in the code that strips the SOAP envelope; it should preserve the namespace context yet it isn't doing so, and that's breaking the XML. I guess that's because it is doing the stripping by taking a substring rather than operating at the DOM element level (whether or not it's using DOM processing to do the stripping is beside the point). I'm not sure which component is doing that stripping because of the way these things can be nested, but I suspect it's WebLogic…
[EDIT]: I've checked the SOAP specification and it does not say that the contents of the body has to directly declare the namespace used (see §5.3.1), though it does say that it SHOULD be namespaced. Because of that, normal XML namespacing rules apply — the whole SOAP message is simply an XML document — and that would make WebLogic's behavior a bug.

Related

Sending file with SOAP MTOM using PowerShell

I am attempting to send a SOAP message with PowerShell that uses MTOM to attach an XML file. MTOM is the method specified by the web service so I don't have the option to include the XML file inline.
I'm getting confused when it comes to actually attaching the file to the SOAP message. I understand that the file is attached using the <xop:Include> element in the SOAP message. But how do I specify the value that should be included for the href attribute (i.e. how do I determine the string that should replace xxxxxxxxx?
In all the examples that I've seen up to now the value for href is always specified as something like 0ccceb3ce8deda6a3a666b587962a26a7524fe64d35d73ea#apache.org but I don't understand how this is generated.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<ns1:RequestAttInfo xmlns:ns1="urn:abb.com:project/isem/types">
<requestType xmlns="">mp.report</requestType>
<adminRole xmlns="">false</adminRole>
<requestDataCompressed xmlns="">false</requestDataCompressed>
<requestDataType xmlns="">XML</requestDataType>
<sendRequestDataOnSuccess xmlns="">true</sendRequestDataOnSuccess>
<sendResponseDataCompressed xmlns="">false</sendResponseDataCompressed>
<requestSignature xmlns="">yyyyyyyyy</requestSignature>
<requestData xmlns="">
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:xxxxxxxxx"></xop:Include>
</requestData>
</ns1:RequestAttInfo>
</soapenv:Body>
</soapenv:Envelope>

Error in WSO2 ESB when calling service without Header element

I believe I found bug in WSO2 ESB.
I defined proxy service for our customer.
With security turned off I always get expected result, but when I enable security (scenario 1 - UsernameToken), then I get error "SOAP Envelope can not have children other than SOAP Header and Body".
I'm able to reproduce this bug with 'echo' service.
Here is request:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:echo="http://echo.services.core.carbon.wso2.org">
<soap:Body>
<echo:echoString>
<in>ABC</in>
</echo:echoString>
</soap:Body>
</soap:Envelope>
Turning security off or adding <soap:Header /> element before <soap:Body> element provides expected response again.
I'm using WSO2 ESB version 4.8.1, SoapUI 5.0.0 as client.
The SOAP headers contain application specific information related to the SOAP message. They typically contain routing information, authentication information, transaction semantics etc.
If you removed <soapenv:Header/> SoapUI will not send your user name and password to rampart.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">
<soapenv:Header/>
<soapenv:Body>
<echo:echoString>
<!--Optional:-->
<in>ABC</in>
</echo:echoString>
</soapenv:Body>
</soapenv:Envelope>
So your error was return by org.apache.axiom.soap.SOAPProcessingException due to AxisEngine System error.
When your sending request to secured one header is must..

JAXWS problem without namespace prefix using Jboss 4.2.3ga

I have a java service published as a JAXWS webservice using #WebServiceannotation. The service is well deployed on Jboss application server 4.2.3ga (with Jax-ws implementation provided by the application server).
The service works well when the Soap message look like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="mynamespace">
<soapenv:Header/>
<soapenv:Body>
<pref:mymethod>
<arg0>value</arg0>
</pref:mymethod>
</soapenv:Body>
</soapenv:Envelope>
And failed when the Soap message look like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="mynamespace">
<soapenv:Header/>
<soapenv:Body>
<mymethod>
<arg0>value</arg0>
</mymethod>
</soapenv:Body>
</soapenv:Envelope>
By fail I mean "mymethod" is invoked, but arg0 is null.
Does anybody know if it is the expected behaviour of JAX-WS api or a bug ? I found no reference to one or to the other.
Does anybody experienced the same problem (or success) using another JAX-WS stack ?
In the working code there is no default namespace and <mymethod> is bound to mynamespace with a prefix.
Because the <arg0> element has no prefix, it is in null namespace.
In the failing code mynamespace is set as the default namespace. Because <mymethod> and <arg0> do not have any prefix, they both have mynamespace as their namespace URI.
It is not allowed to bind the empty namespace URI to any prefix. Therefore you either need to continue to use a namespace prefix in <mymethod> or you need to override the default namespace in <arg0> like this:
<arg0 xmlns="">
Note that this sets all the unprefixed child elements of <arg0> to null namespace unless you override the default namespace again.

Coldfusion Web Service Response Problem

I have a problem with the Web Service I recently developed.
The problem is about the Web Service response. More precisely sometimes the Web Service sends back the following response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:GetConstants2Response soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://usermanagerwstest">
<GetConstants2Return xsi:type="ns2:CFComponentSkeleton" xmlns:ns2="http://rpc.xml.coldfusion"/>
</ns1:GetConstants2Response>
</soapenv:Body>
</soapenv:Envelope>
Instead the correct response (that sometimes shows up in an intermittent way) is reported below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:GetConstants2Response soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://usermanagerwstest">
<GetConstants2Return xsi:type="ns1:Constants2">
<BooleanTypeFalse xsi:type="xsd:string">0</BooleanTypeFalse>
<BooleanTypeTrue xsi:type="xsd:string">1</BooleanTypeTrue>
<GenderFemale xsi:type="xsd:string">F</GenderFemale>
<GenderMale xsi:type="xsd:string">M</GenderMale>
<LanguageEnglish xsi:type="xsd:string">inglese</LanguageEnglish>
<LanguageItalian xsi:type="xsd:string">italiano</LanguageItalian>
</GetConstants2Return>
</ns1:GetConstants2Response>
</soapenv:Body>
</soapenv:Envelope>
Where does the CFCComponentSkeleton comes from?
I thank everybody in advance.
It sounds like perhaps the method was missing. When you hit a CFC and don't pass a method, you get the descriptor - a HTML view of the CFC methods. When you do that with ?wsdl in the URL, it should send the WSDL back. But maybe something is getting in the way. Maybe check your web server logs and see if something odd was passed in the URL. Also look into adding some logging within the CFC as well.

Move namespace declaration from payload to envelope on an axis created web service

I just created a web service client using axis and eclipse that does not work with my web service provider. The message created by the web service client looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<enviarMensajeRequest
xmlns="http://www.springframework.org/spring-ws/Imk-Zenkiu-Services">
<usuario>someuser</usuario>
<clave>somepassword</clave>
<mensaje>somemessage</mensaje>
<contacto>
<buzonSMS>somenumber</buzonSMS>
<primerNombre>somefirstname</primerNombre>
<primerApellido>somelastname</primerApellido>
</contacto>
</enviarMensajeRequest>
</soapenv:Body>
</soapenv:Envelope>
I see nothing wrong with the message but my provider insists the message should be:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:imk="http://www.springframework.org/spring-ws/Imk-Zenkiu-Services">
<soapenv:Body>
<imk:enviarMensajeRequest>
<imk:usuario>someuser</imk:usuario>
<imk:clave>somepassword</imk:clave>
<imk:mensaje>somemessage</imk:mensaje>
<imk:contacto>
<imk:buzonSMS>somenumber</imk:buzonSMS>
<imk:primerNombre>somefirstname</imk:primerNombre>
<imk:primerApellido>somelastname</imk:primerApellido>
</imk:contacto>
</imk:enviarMensajeRequest>
</soapenv:Body>
</soapenv:Envelope>
Notice the namespace declaration moving from the enviarMensajeRequest to the soapenv:Envelope and the qualification with imk: on the parameters. I've tried many combinations on the process but my web service, wsdl and xml knowledge is very limited. The provider says that they can't help beyond telling me this. Any ideas? Perhaps a different framework that I can use to create the correct client.
Your provider is wrong, the messages are semantically equivalent; yours is unqualified, theirs is qualified. Are you using Axis or Axis2? If you're using Axis, I suggest you switch to Axis2 for a more robust, standards-compliant SOAP stack (both products are bad, but Axis2 is less-bad).
I assume you are creating your client with wsdl2java? If you can't get this tool to generate the message the way you like, then your best bet is to generate the message programmatically.
With Axis2, you can do this with the AXIOM API. See this link for some example API usage. Note that with most of the methods, e.g. createOMElement, you optionally pass the namespace prefix. So, if your provider requires it, then you could pass a String containing "imk" as the namespacePrefix parameter.
If you end up doing this programmatically and you are only going to be writing a simple client, then I STRONGLY suggest you abandon the Axis/Axis2 approach and use the JAX-WS stack instead, as it is part of Java since 1.6. The API is cleaner and the documentation is better. For example, following is a very simple client I wrote to send a SOAP request to our JIRA server. The sample code creates both qualified and unqualified elements.
QName port = new QName(endpoint, "subversionsoapservice-v2");
QName serviceName = new QName(endpoint, "ISubversionSoapServiceService");
Service service = Service.create(serviceName);
service.addPort(port, SOAPBinding.SOAP11HTTP_BINDING, endpoint);
Dispatch<SOAPMessage> dispatch = service.createDispatch(port, SOAPMessage.class, Service.Mode.MESSAGE);
MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = factory.createMessage();
SOAPBody body = request.getSOAPBody();
SOAPElement reindexRepository = body.addChildElement("reindexRepository", "jira", "http://soap.ext.plugin.jira.atlassian.com");
SOAPElement in0 = reindexRepository.addChildElement("in0");
in0.addTextNode("test");
request.saveChanges();
dispatch.invoke(request);
The XML sent by the client looks like this:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<jira:reindexRepository xmlns:jira="http://soap.ext.plugin.jira.atlassian.com">
<in0>test</in0>
</jira:reindexRepository>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>