I have developed a soap server but now i had one problem , problem in SOAP ENV and SOAP BODY. My client request form is without soapenv and soapbody
only have a values.
after executing my module export message is
'Unable to create envelope from given source because the root element
is not named Envelope'
but client form could not change.
client form
<?xml version="1.0" encoding="UTF-8"?>
<ns1:inputSOATest xmlns:ns1="http://javainuse.com">
<ns1:requestSet>
<ns2:userInfo xmlns:ns2="http://schemas.datacontract.org/2018/08/SscntBigdata.userInfo">
<ns2:EMPID></ns2:EMPID>
<ns2:SINGLEID/>
<ns2:EPID/>
<ns2:NAME></ns2:NAME>
<ns2:ENGNAME></ns2:ENGNAME>
<ns2:EMPTYPE>PAA</ns2:EMPTYPE>
<ns2:LVABSENCE/>
<ns2:RETIRE/>
<ns2:EMAIL/>
<ns2:TELNUM/>
<ns2:MBPHONE/>
<ns2:BSCADDR></ns2:BSCADDR>
<ns2:ZZBUKRS>J604</ns2:ZZBUKRS>
<ns2:DEPTNM>
<ns2:DEPTNM> China RMD BPL Part</ns2:DEPTNM>
<ns2:SPRAS>1</ns2:SPRAS>
</ns2:DEPTNM>
<ns2:DEPTNM>
<ns2:DEPTNM> BPL Part</ns2:DEPTNM>
<ns2:SPRAS>3</ns2:SPRAS>
</ns2:DEPTNM>
<ns2:PDEPTNM>
<ns2:PDEPTNM></ns2:PDEPTNM>
<ns2:SPRAS>3</ns2:SPRAS>
</ns2:PDEPTNM>
<ns2:PDEPTNM>
<ns2:PDEPTNM></ns2:PDEPTNM>
<ns2:SPRAS>E</ns2:SPRAS>
</ns2:PDEPTNM>
<ns2:CORPNM>
<ns2:CORPNM>ion Trading</ns2:CORPNM>
<ns2:SPRAS>E</ns2:SPRAS>
</ns2:CORPNM>
<ns2:CORPNM>
<ns2:CORPNM>Trading</ns2:CORPNM>
<ns2:SPRAS>3</ns2:SPRAS>
</ns2:CORPNM>
<ns2:JOBNM>
<ns2:JOBNM></ns2:JOBNM>
<ns2:SPRAS>3</ns2:SPRAS>
</ns2:JOBNM>
<ns2:JOBGRDNM>
<ns2:JOBGRDNM>()</ns2:JOBGRDNM>
<ns2:SPRAS>3</ns2:SPRAS>
</ns2:JOBGRDNM>
<ns2:JOBGRDNM>
<ns2:JOBGRDNM></ns2:JOBGRDNM>
<ns2:SPRAS>1</ns2:SPRAS>
</ns2:JOBGRDNM>
</ns2:userInfo>
</ns1:requestSet></ns1:inputSOATest>
how do i can that?
SOAP msgs are always in SOAP-ENV, SOAP-HEADER and SOAP-BODY format.
I can see your request has inputSOATest tag. If I am understanding currectly. Client data is from SOA. I thnk you have to convert SOA test to proper SOAP msg before sending to server.
Related
I am using camel framework 2.22.0 and camel-spring-ws in my spring boot microservice to convert xml into soap at runtime and make a request to backend and same time receive the soap response and coverts it back to XML before sending the response back to calling system.
Success scenarios are all working fine but when soap fault it only logs the soap string and can't see any soap response been populated. soap response is not getting captured and doesn't get back to calling system apart from http status code 500.
The below is what backend system is sending as soap fault. I can't see anything in camel exchange body populated with soap fault. I need to capture the xml response in detail tag section and to send back to calling system.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>abc-complex-type.x.x: Value '0' of attribute 'schemaVersion' of element 'ABCSubmission:ABCSubmission' is not valid with respect to the corresponding attribute use. Attribute 'schemaVersion' has a fixed value of '1'.</faultstring>
<detail>
<ns2:ABCSubmissionException xmlns:ns2="java:com.webservice.ejb" xmlns="ABCintegration.xdt">
<ns2:ABCIntegrationError schemaVersionMajor="1" schemaVersionMinor="0">
<ErrorName>ABCMessageSyntaxInvalid</ErrorName>
<ErrorDescription>cvc-complex-type.3.1: Value '0' of attribute 'schemaVersion' of element 'ABCSubmission:ABCSubmission' is not valid with respect to the corresponding attribute use. Attribute 'schemaVersion' has a fixed value of '1'.</ErrorDescription>
</ns2:ABCIntegrationError>
</ns2:ABCSubmissionException>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Camel differentiates between Exceptions and Faults (historic reasons). Unfortunately this seems to be missing in the Camel Documentation.
If you want that Camel treats Faults the same as Exceptions (handled by the Camel error handler), you have to set
.handleFault()
You can set this globally on the Camel Context or on specific routes. See also the comment at the bottom of this page
I am using java spring webservice to send soap requests to a server. However I get an error from the server saying
The security context token is expired or is not valid
So then I added authentication to the SOAP headers, resulting in request xml something like this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<UsernameToken>
<Username>XXXXXXXX</Username>
<Password>XXXXXXXX</Password>
</UsernameToken>
</Security>
</env:Header>
<env:Body>
The body is in the correct format here
</env:Body>
</env:Envelope>
But I still get that error. From what I understand, the client sends authentication credentials to the server, the server sends back requestToken which is used to keep connection alive between client and server and then client using the token received from the server can make any other API calls such as login, buy, sell (or whatever mentioned in API)
Am I right in this assumption? If yes, how can this be implemented using Java Spring WebServices. Do I need to generate fields on client side like BinarySecret and package that under RequestSecurityContext?
For adding the SOAP headers, I wrote a class which implements WebServiceMessageCallback and overrides doWithMessage method and writes headers in that for username and password (i.e security)
Any help would be appreciated! Thank You!
So after 2 days of finding out, I was able to figure out the solution!
1) Generate the classes from wsdl using CXF wsdl2java
2) Make sure in the pom file, you point to the correct wsdlLocation
3) Get the stub from the service class generated and inject username and password provided and then it should work. Something like this:
final YourService service = new YourService();
final YourStub stub = service.getService();
final Map ctx = ((BindingProvider)stub).getRequestContext();
ctx.put("ws-security.username", userName);
ctx.put("ws-security.password", password);
stub.callYourMethod();
PS: Please make sure you have the right libraries, I just used cxf-bundle and nothing else from cxf and it worked! Earlier it was not working as I had individually included libraries from cxf.
I am new to SOAP and need to extract an XML payload from a SOAP message. Our application is contacting a soap service, and the service is returning an XML Document that is embedded within a SOAP message. I need to extract this XML that is within the SOAP body, and save it as a "stand alone" well formed XML document. What is the best way to go about this?
If I send a request with the header like as below .,
<S:Header>
<ns2:transId xmlns="http://test.ws.com/testws"
xmlns:ns2="http://test.db.com/db9">123ASD89EDFE7363</ns2:transId>
</S:Header>
its working fine for success responses also there is no unnecessary namespace exist in the header. But error cases, the response from the web service is sent with the two namespaces using same default identifiers for the header element as like below.,
<S:Header>
<transId xmlns="http://test.ws.com/testws"
xmlns="http://test.db.com/db9">123ASD89EDFE7363</transId>
</S:Header>
because of the above format, the client application is unable to parse the responses.
the client artifact is generated using the clientgen from the wsdl. can anyone please help to find the resolution for the above issue.
Thanks in advance.
Can you describe the issue a little more?
It sounds like you're making an HTTP request with a header that has the value "123ASD...", and that when the server responds with OK (200) then it works as expected, but that when the server responds with an error condition (4xx-5xx) then the response it bad.
is it duplicating the same header twice in the HTTP response headers?
Or is it sending an extra request (like perhaps a redirect)?
Like
GET gets a 301 repsonse with the header and then maybe it sends to an error page but it uses the same header twice or something?
A little more information about the header value (does it change every time?) might help...
Thanks for your response. its a SOAP message with header and body over HTTP and there is no issues with the HTTP. error response is like the soap fault or schema validation error from the server when we send bad soap requests. Its not duplicating the header, but when a soap request sent with the unnecessary namespace xmlns="http://test.ws.com/testws" (it has nothing to do with the header elements but my client app adds this everytime when it sends request ), the web service returns the response including the above one and the needed namespace of xmlns="http://test.db.com/db9". my question is the web service is not using different identifiers when it sends two namespaces. the header value is static during one transaction like sessionid.
I am new to webservices,some how i managed to host a service with metro.With the help of SOAP UI and also httpUrlConnection object i am able to get SOAP response.But my next task is to send a response with content type "application/xml".So i used httpServletResponse,but i am not getting how to extract only XML part(without SOAP envolope and SOAP header) and also how to send XML inside respose object.Whether the way in which i am doing is rite?If yes,how to proceed with next step.
There are various ways to send xml content within SOAP response. To keep wsdl and xsd simple, you may use CDATA for your xml content and parse like a string on the receiving end.
<![CDATA[YOUR XML GOES HERE]]>
If you want to parse SOAP message and extract XML then you may want to use Java API SAAJ