How to remove soap namespace from Envelope using Apache CXF - soap

I am trying to access a 3rd party web service using Apache CXF 3.1. When I call the service with the wsdl2java generated code or curl the service returns an exception indicating the message is not a valid SOAP message. See the message below.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<connectivityTest xmlns="urn:cdc:iisb:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="connectivityTest">
<echoBack>Hello IIS!</echoBack>
</connectivityTest>
</soap:Body>
</soap:Envelope>
When I remove the namespace (soap:) and call the service using curl the service works. See working message below.
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
<Body>
<connectivityTest xmlns="urn:cdc:iisb:2011" xmlns:ns2="http://www.w3.org/2003/05/soap-envelope">
<echoBack>Hello IIS V2!</echoBack>
</connectivityTest>
</Body>
How do I remove the namespace from the Envelope and Body elements of my SOAP message before it sent? Based on searching the web it looks like I may need to create an interceptor. If some one can provide an example of an interceptor to remove the namespace from the Envelope and Body elements it would be much appreciated.
Thanks in advance!
JR

No Interceptor is required for this. You can configure the namespace in your jaxws properties.
<jaxws:properties>
<entry key="soap.env.ns.map">
<map>
<entry key="" value="http://schemas.xmlsoap.org/soap/envelope/"/>
</map>
</entry>
<entry key="disable.outputstream.optimization" value="true"/>
</jaxws:properties>

Related

Version mismatch from SOAP API

I am calling SOAP API from postman with following request.
<?xml version="2.0" ?>
<Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<get xmlns:S="http://xml.abc.com/cde/2.xsd" xmlns:S="http://ws.abc.com/cde.2">
<sid>2</sid>
</get>
</Body>
</Envelope>
But, it is giving following response.
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:VersionMismatch</faultcode>
<faultstring>Couldn't create SOAP message. Expecting Envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, but got </faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
Can someone help me, what am I doing wrong.
Your Soap Envelope namespace is incorrect, your request should be something like--
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<ns1:get xmlns:ns1="http://ws.abc.com/cde.2">
<ns1:sid>2</ns1:sid>
</ns1:get>
</soap:Body>
</soap:Envelope>
It is related to the SOAP version. SOAP 1.2 uses http://www.w3.org/2003/05/soap-envelope for the namespace and SOAP 1.1 uses http://schemas.xmlsoap.org/soap/envelope/.
For reference, see http://www.w3.org/TR/soap/ and look at the envelope section in the different version specs.

Issue in SOAP message generated by Embarcadero

I have created an application developped by Embarcadero XE5 C++. I use THTTPRio to consume a web service.
I have a problem with the request message generated by our application. It seems that namespaces are missing in the soap message for NS1, NS2 and NS3.
I think there's a bug in the Embarcadero.
Here the SOAP request message generated by Embarcadero:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<G110Request xmlns="urn:wsdltypes.nmvs.eu:v1.0">
<Header xmlns="urn:types.nmvs.eu:v1.0">
<Auth>
<ClientLoginId>xxx</ClientLoginId>
<UserId>xxx</UserId>
<Password>xxx</Password>
</Auth>
<UserSoftware NS1:name="xxxxx" NS2:supplier="xxxx"/>
</Header>
<Body xmlns="urn:types.nmvs.eu:v1.0">
<Product>
<ProductCode NS3:scheme="GTIN">1234567891234</ProductCode>
</Product>
</Body>
</G110Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Thanks for your help

How exactly works this payloadFactory chained with an header mediator in a WSO2 ESB project?

I am absolutly new in WSO2 and I am working on a WSO2 Enterprise Integrator project containing this ESB project section (I think that my question is only related to ESB).
So my doubt is: I have an XML file defining an API. The flow starts with a payloadFactory mediator, something like this:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/xxxTest2" name="xxxTest2" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<!-- Create empty message to get all samples from DSS -->
<!-- Get Sample ID -->
<payloadFactory media-type="xml">
<format>
<body/>
</format>
<args>
<arg evaluator="xml" expression="get-property('uri.var.int_val')" xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd"/>
</args>
</payloadFactory>
<!--
Adding an header that defines the actionr related to the "FindNotProcessed" DSS service
used to retrieve all the unprocessed resource on the DB
-->
<header name="Action" scope="default" value="urn:FindNotProcessed"/>
<!-- Log the request generated by the previous payloadFactory mediator: -->
<log level="full"/>
...............................................................
...............................................................
...............................................................
</api>
My doubt is: this payloadFactory mediator generate and empty message because its content is:
<format>
<body/>
</format>
The next element in the chain is the header mediator:
<header name="Action" scope="default" value="urn:FindNotProcessed"/>
used to set a new header having name="Action" that specify (as value) the name of a DSS service to obtain some data from the DB.
Finnally the next element in the chain is a log mediator. It seems to me that is is used to log the message generated by the concatenation of the previous payloadFactory mediator chianed with the following header mediator.
This log mediator generate this log:
TID: [-1234] [] [2017-03-28 10:05:30,943] INFO {org.apache.synapse.mediators.builtin.LogMediator} -
To: /glisTest2, WSAction: urn:FindNotProcessed, SOAPAction: urn:FindNotProcessed, MessageID: urn:uuid:95913219-2ad1-4488-a260-78693f3bbde2, Direction: request,
Envelope:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<body xmlns="http://ws.apache.org/ns/synapse"/>
</soapenv:Body>
</soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
My doubts are:
1) Why is it generating an XML message that embedd a soapenv structure?
2) It depends by the fact that the header meadiator defines scope="default" that should coincide to Synapse. Because reading the official documentation:
https://docs.wso2.com/display/ESB481/Header+Mediator
it says:
Scope: Select Synapse if you want to manipulate SOAP headers. Select
Transport if you want to manipulate HTTP headers.
so I think that settings in this way is generating a SOAP message and so is the reason because my message is into the soapenv structure.
Is it or am I missing something?
By default, all the messages in the WSO2 EI/ESB will be treated as SOAP messages, that's why your payload is enclosed in the soap envelope.
Headers actually work when you send the message to an endpoint, so if you have an endpoint http://hostname:port/abc/xyz , the Action (Soap Action) of the message will be set as urn:FindNotProcessed. It means that the message will go to the urn:FindNotProcessed operation of the endpoint, provided the endpoint is a soap endpoint.
Thanks

Request to web services failed using php, succeeded from windows client

I have written a web service using asp.net 2.0 and a simple method "HelloWorld" to test it. Here is the soap envelope which the server receives:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<SoapAuthHeader xmlns="http://myservice.anywhere.net/">
<UserName>MyUser</UserName>
<Password>MyPassword</Password>
</SoapAuthHeader>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://myservice.anywhere.net/">
<request>
<?xml version="1.0" encoding="utf-16"?>
<HelloWorld />
</request>
</HelloWorld>
</soap:Body>
</soap:Envelope>
My Problem is: If I send the request from a Windows Client with embedded wsdl it succeeds. If I send the request from php (or SoapUI) the request fails - the server gets no "request" string, means no content for the body.
The server receives in both cases the same soap envelope above (logged it with a trace extension).
Thanks for any help.
Harald
P.S. No matter if I use embedded XML or embedded string for the request.
Using the asmx trace I have found the problem at least with SoapUI. The requested requirement category was "text/xml" and it got "application/soap+xml". I have disabled "Soap action" and the call succeeds.

coldfusion publish webservice using SOAP

I am trying to create a web service that can be consumed with SOAP. I were exercising with normal webservices that returns any values, but know i want to check which elements in the SOAP:BODY are needed and return them with a response. I found the methods
GetSoapRequest()
and
AddSoapResponse()
in the livedoc from adobe, but don't understand how to use them.
I saw the explenation of a request and response on w3school.com
i tried to solve the Problem with the tags "cfsavecontent"
<cffunction
name="soap"
access="remote"
returntype="any"
output="false">
<cfsavecontent variable="soapMessage">
<?xml version="1.0">
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
</soap:Header>
<soap:Body>
<m:GetPriveResponse xmlns:m="namespace">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
</cfsavecontent>
but it only works, if the cffunction has returntype="any". The type "xml" occurs an error.
thx for helf
The easiest way to create a web service in CF, see
Creating components for web services http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13a13-7fe2.html
Publishing web services
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-78b7.html
I just installed the soapUI eclipse addon and called the WSDL that includes an argument of a complexe type. After testing the methods of my web service with the addon, I got the SOAP-Message I was searching all the time. Maybe it will help anybody, i just where searching long time for this solution.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://components.conner.somebody">
<soapenv:Header/>
<soapenv:Body>
<com:echoAddress soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<input xsi:type="com:Address">
<City xsi:type="xsd:string">?</City>
<Country xsi:type="xsd:string">?</Country>
<State xsi:type="xsd:string">?</State>
<Street xsi:type="xsd:string">?</Street>
</input>
</com:echoAddress>
</soapenv:Body>
</soapenv:Envelope>
Here is the method of the coldfusion component that will be called
<cffunction
name="echoAddress"
returnType="address"
output="false"
access="remote">
<cfargument
name="input"
type="address">
<cfreturn #arguments.input#>
</cffunction>