Create parent element in SOAPBody response using SOAPHandler - java

I am using SOAPHandler and I need to modify my SOAPMessage in SOAPNHandler:
The message i get:
<soapenv:Envelope xmlns:soapenv="...">
<soapenv:Header/>
<soapenv:Body>
<CC>
<Dat>210520</Dat>
<Tim>1156</Tim>
<MesI>20210000000830</MesI>
<MesT>CC616A</MesT>
<HEA>
<Dec>202105201156</Dec>
</HEA>
</CC>
</soapenv:Body>
</soapenv:Envelope>
I need to add a parent element AA to the body, and get this result:
<soapenv:Envelope xmlns:soapenv="...">
<soapenv:Header/>
<soapenv:Body>
<AA>
<CC>
<Dat>210520</Dat>
<Tim>1156</Tim>
<MesI>20210000000830</MesI>
<MesT>CC616A</MesT>
<HEA>
<Dec>202105201156</Dec>
</HEA>
</CC>
</AA>
</soapenv:Body>
</soapenv:Envelope>
And i can´t figure it out. I hope someone can help me.
Thank you.

Related

It is possible to have table in request wsdl file in soup ui?

Can someone explain it is possible to create table in wsdl file ?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="http://DefaultNamespace">
<soapenv:Header/>
<soapenv:Body>
<def:addCompany>
<def:invoiceType>
<def:invoiceId>?</def:invoiceId>
<def:header1>?</def:header1>
<def:header2>?</def:header2>
<!--1 or more repetitions:-->
<def:invoiceReturn>
<def:invoiceNumber>?</def:invoiceNumber>
<def:InvoiceOrder>?</def:InvoiceOrder>
<def:totalValue>?</def:totalValue>
</def:invoiceReturn>
<!--1 or more repetitions:-->
<def:category>
<def:categoryId>?</def:categoryId>
<def:categoryName>?</def:categoryName>
</def:category>
</def:invoiceType>
</def:addCompany>
</soapenv:Body>
</soapenv:Envelope>
i have something metod like addINvoice with my header now i want to add to this method the table for exaple 3 columns mpk rk and total it is possible in wsdl ?

How can I change response xml in JAX-WS

I have the following XML as my JAX-WS web service response:
<soapenv:Envelope>
<soapenv:Header/>
<soapenv:Body>
<QueryRBTReqMsgResponse>
<QueryRBTRspMsg>
<resultHeader>
<resultCode>0</resultCode>
<resultDesc>Successful</resultDesc>
</resultHeader>
<!--Optional:-->
<QueryRBTResponse>
<part>1</part>
</QueryRBTResponse>
</QueryRBTRspMsg>
</QueryRBTReqMsgResponse>
</soapenv:Body>
</soapenv:Envelope>
But this is what I want:
<soapenv:Envelope>
<soapenv:Header/>
<soapenv:Body>
<QueryRBTRspMsg>
<resultHeader>
<resultCode>0</resultCode>
<resultDesc>Successful</resultDesc>
</resultHeader>
<!--Optional:-->
<QueryRBTResponse>
<part>1</part>
</QueryRBTResponse>
</QueryRBTRspMsg>
</soapenv:Body>
</soapenv:Envelope>
How can I remove the <QueryRBTReqMsgResponse> tag from my response? I tried too many changes but none of them did the job!!!
Finally I found the solution. We have to use following annotation:
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)

Error receiving SOAP request values

I'm receiving a SOAP request like this, but my service can´t load the values
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://schemas.xmlsoap.org/soap/envelope/"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header
xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>
<soapenv:Body
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Operation xmlns="http://www.schema.com/SoS"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
...
But if I remove some of the requests tags, leaving only this
everything works ok:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header
xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>
<soapenv:Body>
<doOperation
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
...
For an easier reading, I removed xmlns="http://www.schema.com/SoS" from Operation, xmlns="http://schemas.xmlsoap.org/soap/envelope/" from soapenv:Envelope and xmlns="http://schemas.xmlsoap.org/soap/envelope/" from soapenv:Body.

Soap request with namespace

I have web service client and when i send request, the soap message looks like
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<Open xmlns="ttt:some:namespace">
<PartnerName>SomeParther</PartnerName>
<NumberToS>1</NumberToS>
</Open>
</S:Body>
</S:Envelope>
and this incorrect message. The correct message looks like
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="ttt:some:namespace">
<soapenv:Header />
<soapenv:Body>
<ttt:Open>
<ttt:PartnerName>SomeParther</ttt:PartnerName>
<ttt:NumberToS>1</ttt:NumberToS>
</ttt:Open>
</soapenv:Body>
</soapenv:Envelope>
how i do soap request
So_Service soService = new So_Service();
SoPort soPort = soService.getSoaphaSOAP();
/* test */
System.out.println("getServiceName from So_Service" + soService.getServiceName());
soPort.open("SomeParther", 1);
output getServiceName from So_Service ttt:some:namespace
What I'm doing wrong? What should i do for correct generate the message? Please Help
Try the below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="ttt:some:namespace">
<soapenv:Header />
<soapenv:Body>
<urn:Open>
<urn:PartnerName>SomeParther</urn:PartnerName>
<urn:NumberToS>1</urn:NumberToS>
</urn:Open>
</soapenv:Body>
</soapenv:Envelope>

SOAP request payload

I have a webservice where request payload is as follows
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:poc="http://www.poc.mbo.demo.com">
<soapenv:Header/>
<soapenv:Body>
<poc:doTransaction>
<!--Optional:-->
<dealerid>1</dealerid>
<!--Optional:-->
<partid>1</partid>
<!--Optional:-->
<quantity>2</quantity>
<!--Optional:-->
<orderdate>12-DEC-2012</orderdate>
</poc:doTransaction>
</soapenv:Body>
</soapenv:Envelope>
But if i try like this its giving no response. what could be the issue
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:poc="http://www.poc.mbo.demo.com">
<soapenv:Header/>
<soapenv:Body>
<poc:doTransaction>
<!--Optional:-->
<poc:dealerid>1</poc:dealerid>
<!--Optional:-->
<poc:partid>1</poc:partid>
<!--Optional:-->
<quantity>2</quantity>
<!--Optional:-->
<poc:orderdate>12-DEC-2012</poc:orderdate>
</poc:doTransaction>
</soapenv:Body>
</soapenv:Envelope>
The doTransaction elements in the first sample are not in the http://www.poc.mbo.demo.com namespace.
Your request either fails validation (assuming validation is enabled) or the server ignores the invalid elements and treats the request as being equivalent to:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:poc="http://www.poc.mbo.demo.com">
<soapenv:Header/>
<soapenv:Body>
<poc:doTransaction />
</soapenv:Body>
</soapenv:Envelope>
As per the WSDL of ur service the element would have assosiated with a namespace (a XSD), but the others may be part of another namespace (XSD),
To understand that clearly just check the WSDL the type section and the operation , check which type(Element) is assciated with which XSD.. u can easily understand y it is failing..
Think namespace as imported class and type as it's one of the state(:) Just for easy understanding)

Categories