I am trying to create following soap message programatically using javax.xml.soap.* classes.
How can I produce this xml exactly?
when I create the xml message root tage begins with <SOAP-ENV:Envelope instead of <env:Envelope
<?xml version="1.0" encoding='ISO-8859-9'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<mm7:TransactionID
xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"
env:mustUnderstand="1">
TXN_ID-2011521232323
</mm7:TransactionID>
</env:Header>
<env:Body>
<mm7:SubmitReq xmlns:mm7="urn:mm7SubmitReq">
<MM7Version>5.6.0</MM7Version>
<Content allowAdaptations="true" />
<MessageClass>1</MessageClass>
</mm7:SubmitReq>
</env:Body>
</env:Envelope>
as Tim suggested the prefix name should not matter.
the prefix SOAP-ENV comes from com.sun.xml.internal.messaging.saaj.soap.name.NameImpl#SOAP_ENVELOPE_PREFIX
you can modify this using reflection. but It is not recommended to do so.
Related
I am attempting to parse a request that I am receiving at one of the end-points I have created in MuleSoft.
This is a SOAP Request coming from Salesforce, I wan't to be able to just get the XML and grab a value from it. The soap request message is below.
SAMPLE SOAP REQUEST:
<?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>
<notifications
xmlns="http://soap.sforce.com/2005/09/outbound">
<OrganizationId>00123jhk1h230AQ</OrganizationId>
<ActionId>04215wergf2345AA0</ActionId>
<SessionId>00Dn00000008w1T!AQ0AQLiuZg345345EGC8LAY00OqInU_Exn4.FVinnwwc2j.Naerwt2323g0R4qi9ykmHt.eertert212342dh</SessionId>
<EnterpriseUrl>https://12fwghoft.cs50.my.salesforce.com/services/Soap/c/39.0/00Dn00000008w1T</EnterpriseUrl>
<PartnerUrl>https://12fwghoft.cs50.my.salesforce.com/services/Soap/u/39.0/00Dn00000008w1T</PartnerUrl>
<Notification>
<Id>04l45611902IG</Id>
<sObject xsi:type="sf:Account"
xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
<sf:Id>00q2sv2224ggwAV</sf:Id>
</sObject>
</Notification>
</notifications>
</soapenv:Body>
</soapenv:Envelope>
MULE INBOUND MESSAGE DETAILS:
org.mule.DefaultMuleMessage
{
id=114f2110-0058-11e7-9989-5ce0c55142df
payload=[Ljava.lang.Object;
correlationId=<not set>
correlationGroup=-1
correlationSeq=-1
encoding=UTF-8
exceptionPayload=<not set>
Message properties:
INVOCATION scoped properties:
_ApikitResponseTransformer_AcceptedHeaders=*/*
_ApikitResponseTransformer_apikitRouterRequest=yes
_ApikitResponseTransformer_contractMimeTypes=[]
cxf_operation={http://soap.sforce.com/2005/09/outbound}notifications
cxf_service={http://soap.sforce.com/2005/09/outbound}NotificationPortService
method=public abstract boolean sfdc.account.NotificationPort.notifications(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List)
INBOUND scoped properties:
accept-encoding=gzip
cache-control=max-age=259200
content-length=1028
content-type=text/xml; charset=utf-8
host=36ce69be.ngrok.io
http.listener.path=/api/*
http.method=POST
http.query.params=ParameterMap{[]}
http.query.string=
http.relative.path=/api/netsuite/customers
http.remote.address=/127.0.0.1:59266
http.request.path=/api/netsuite/customers
http.request.uri=/api/netsuite/customers
http.scheme=http
http.uri.params=ParameterMap{[]}
http.version=HTTP/1.1
soapaction=""
user-agent=Jakarta Commons-HttpClient/3.1
x-forwarded-for=136.147.62.8
OUTBOUND scoped properties:
MULE_ENCODING=UTF-8
SESSION scoped properties:
}
You can extract SOAP message body part xml using below simple xsl code with the XSLT transformer step.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:outbound="http://soap.sforce.com/2005/09/outbound">
<xsl:template match="/">
<xsl:copy-of select="/soapenv:Envelope/soapenv:Body/outbound:notifications"/>
</xsl:template>
</xsl:stylesheet>
you can Use CXF component with proxy-service operation in order to extract SOAP message body as Payload
ex:
<cxf:proxy-service port="tmddOCSoapHttpServicePort" namespace="http://www.tmdd.org/3/dialogs" service="TmddOwnerCenterService" payload="body" wsdlLocation="classpath:/TMDD.wsdl" enableMuleSoapHeaders="false" metadata:id="533a80dc-8f06-42c6-9646-a461196dfd72" doc:name="TmddOwnerCenterService">
</cxf:proxy-service>
I have this SOAP Request that simply checks the balance of an account.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="urn:someurn">
<SOAP-ENV:Body>
<Execute xmlns="">
<sessionId xmlns="">SomeSessionID</sessionId>
<username xmlns="">SomeUserName</username>
<password xmlns="">SomePassword</password>
<command xmlns="">CommandName</command>
<data xmlns=""><?xml version="1.0"?><meta><accountNo></accountNo></meta>
</data>
</Execute>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Whenever I make the request this error occurs, I have read some stack questions regarding this that I need to clear that whitespaces I've already done that, I've also tried using html entities for the question marks still no avail.
The error is :XML error parsing SOAP payload on line 14: Reserved XML Name which is the data tag.
Anyone can help me here? Also, I'm using Java to make the Requests to the the server.
Line 14 is
<data xmlns=""><?xml version="1.0"?><meta><accountNo></accountNo></meta>
You cannot have an xml header (the <?xml...?> tag) anywhere in the XML except as the first line. You must encode everything inside the <data>...</data> using entities, as in:
<data xmlns=""><?xml version="1.0"?><meta> ...
I am getting soap response from web service. I need to parse to get the value inside the node. Please provide some code to parse the soap response.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:Response xmlns:ns3="http://www.example.org/Response" userid="100">
<name date="23-10-2013">Sample</name>
<name date="02-09-2013">Hello</name>
</ns3:Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I generate a Web Service Client with the assistant of Eclipse passing the WSDL of the provider Web Service.
I generate in a JUnit test case the object to pass to the Web Service.
//After set properties of the request object
AbacusWebService wsAbacus = new AbacusWebService();
WebServiceResult wsResult = wsAbacus.irsValoration(requestObject);
With the monitor TCP-IP of Eclipse I see the the request and the response and both are correct. The response returns data:
<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>
<irsValorationResponse xmlns="http://webServices.isban.es">
<irsValorationReturn>
<error xsi:nil="true"/>
<format>dd/MM/yyyy</format>
<pricingDate>02/09/2012</pricingDate>
<results>
<results>
<bpv>-492.6493116525817</bpv>
<cer xsi:nil="true"/>
<chargeRunning xsi:nil="true"/>
<chargeUpfront xsi:nil="true"/>
<error xsi:nil="true"/>
<gamma>0.004649336915463209</gamma>
<gammaTotal xsi:nil="true"/>
<minCerReturn xsi:nil="true"/>
<name>IRS</name>
<npv>46371.877687584296</npv>
<payingNpv>0.0</payingNpv>
<pricingDelta>433.0423619134596</pricingDelta>
<receivingNpv>46371.877687584296</receivingNpv>
<swapRate>0.9412756009346844</swapRate>
</results>
</results>
</irsValorationReturn>
</irsValorationResponse>
</soapenv:Body>
But when I inspect the response object (wsResult), all of their properties are null.
Can anyone help me?
Thanks in advance.
I want to parse one xml file whose one of the tag/node having another xml file as a data so how could i parse that file.following is the xml file:
<?xml version="1.0"?>
<company>
<URL>
<RequestUrl>http://www.google.com
</RequestUrl>
<RequestData>
"<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><PingMe xmlns="visum.Server.Service" id="o0" c:root="1"><Data i:type="d:string">ping</Data></PingMe></v:Body></v:Envelope>"
</RequestData>
</company>
when i am going to parse the above xml file & retrieve the xml file under Request Data tag it is not returning me whole string of another xml file but only blank string so how should i proceed for that?
Parse this instead. You have to use CDATA in order for your extra "XML" to not be interpreted.
<?xml version="1.0"?>
<company>
<URL>
<RequestUrl>http://www.google.com</RequestUrl>
<RequestData>
<![CDATA[
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><PingMe xmlns="visum.Server.Service" id="o0" c:root="1"><Data i:type="d:string">ping</Data></PingMe></v:Body></v:Envelope>
]]>
</RequestData>
</URL>
</company>