Have a SOAP response that I can't parse into NodeList.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soap-env:Envelope 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">
<soap-env:Body>
<s0:response xmlns:s0="urn:company.processing.messages">
<newOutput>
<messageType>OKAY</messageType>
<messageCode>00000000</messageCode>
<messageText>SUCCESSFUL</messageText>
</newOutput>
</s0:response>
</soap-env:Body>
</soap-env:Envelope>
Returns NullPointerException:
SOAPMessage soapMessage = ((SaajSoapMessage) messageContext.getResponse()).getSaajMessage();
NodeList nodeList = soapMessage.getSOAPBody().getChildNodes().item(0).getFirstChild().getChildNodes();
My guess something is wrong with the the format of this message but can't figure out what exactly is wrong.
The issues was with XML formatting. Resolved.
Related
I want to send a java soap req to a web service:
url: (https://webapplicaties.agro.nl/OpvragenPandEnergieLabel/EpbdOpvragenPandEnergieLabelService.asmx?WSDL)
This is the request:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:epb="http://schemas.ep-
online.nl/EpbdOpvragenPandEnergieLabelHeader"
xmlns:epb1="http://schemas.ep-
online.nl/EpbdOpvragenPandEnergieLabelRequest">
<soapenv:Header>
<epb:PandEnergieLabelHeader>
<epb:username>username</epb:username>
<epb:password>password</epb:password>
<epb:versienr>4</epb:versienr>
</epb:PandEnergieLabelHeader>
</soapenv:Header>
<soapenv:Body>
<epb1:GetPandEnergieLabel>
<epb1:Pand_postcode>postcode</epb1:Pand_postcode>
<epb1:Pand_huisnummer>housnr</epb1:Pand_huisnummer>
<epb1:Pand_huisnummer_toev>extra</epb1:Pand_huisnummer_toev>
</epb1:GetPandEnergieLabel>
</soapenv:Body>
</soapenv:Envelope>
and the response should be like this.
Which steps should I take to have a such a response?
<?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:Body>
<PandEnergieLabel xmlns="http://schemas.ep-online.nl/EpbdExportTypes">
<Pand_gebouwklasse>W</Pand_gebouwklasse>
<Pand_is_op_basis_van_referentie_gebouw>false</Pand_is_op_basis_van_referentie_gebouw>
<Pand_opnamedatum>29-04-2011</Pand_opnamedatum>
<Pand_berekeningstype>EP</Pand_berekeningstype>
<Pand_energieprestatieindex>1.21</Pand_energieprestatieindex>
<Pand_energieklasse>B</Pand_energieklasse>
<Pand_energielabel_is_prive>false</Pand_energielabel_is_prive>
<Pand_forfaitaire>1.21</Pand_forfaitaire>
<Meting_geldig_tot>29-04-2021</Meting_geldig_tot>
<Pand_registratiedatum>29-04-2011</Pand_registratiedatum>
<Pand_postcode>1072XC</Pand_postcode>
<Pand_huisnummer>79</Pand_huisnummer>
<Pand_huisnummer_toev>A</Pand_huisnummer_toev>
<Pand_gebouwcode />
<Pand_gebouwtype>Portiekwoning</Pand_gebouwtype>
<Pand_gebouwsubtype>Tussenvloer</Pand_gebouwsubtype>
</PandEnergieLabel>
</soap:Body>
</soap:Envelope>
How should I use Variables inside the request to ask for multiple addresses (postcode, housnr, ...)
Thanks
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'm using a endpoint SOAP created On Spring Framework using JAXB, but I want that my anwers(Expected Response) return without prefix when I Send Request One, but this is returned like is showed on Current Response:.
How can I do to return a message SOAP without namespaces?
Request One
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style">
<soapenv:Header/>
<soapenv:Body>
<urn:ZProveerDatosPagoProveed2>
<Bukrs>RG10</Bukrs>
<Langu>S</Langu>
<Lifnr>00000000</Lifnr>
</urn:ZProveerDatosPagoProveed2>
</soapenv:Body>
</soapenv:Envelope>
Current Response:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<n0:ZProveerDatosPagoProveed2Response xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">
<Adrnr>0000</Adrnr>
<Bankk>0000</Bankk>
<Bankn>0000</Bankn>
<Bkont>0000</Bkont>
<Iban>ES0000</Iban>
<KoinhFi>ROBLES AVN</KoinhFi>
<Land1>TH</Land1>
<Landx>XXXXX</Landx>
<Name1>ROBLES AVN</Name1>
<Pstlz>0000</Pstlz>
<Stcd1>A0000</Stcd1>
<Stras>ROBLES AVN</Stras>
<Swift>XXXXX</Swift>
<Text1_052>ROBLES AVN</Text1_052>
<Zterm>Z000</Zterm>
</n0:ZProveerDatosPagoProveed2Response>
</soap-env:Body>
</soap-env:Envelope>
Expected Response:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<ZProveerDatosPagoProveed2Response xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">
<Adrnr>0000</Adrnr>
<Bankk>0000</Bankk>
<Bankn>0000</Bankn>
<Bkont>0000</Bkont>
<Iban>ES0000</Iban>
<KoinhFi>ROBLES AVN</KoinhFi>
<Land1>TH</Land1>
<Landx>XXXXX</Landx>
<Name1>ROBLES AVN</Name1>
<Pstlz>0000</Pstlz>
<Stcd1>A0000</Stcd1>
<Stras>ROBLES AVN</Stras>
<Swift>XXXXX</Swift>
<Text1_052>ROBLES AVN</Text1_052>
<Zterm>Z000</Zterm>
</ZProveerDatosPagoProveed2Response>
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>
The service at this address http://www.cs12333.com:8001/Service/PersonSearchService returns the following XML:
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:findPersonListResponse xmlns:ns2="http://service.person.search/">
<return>
<result>true</result>
<resultList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:grxxBean">
<aab001>cooperation</aab001>
<aac001>34305742</aac001>
<aac002>430423198906237024</aac002>
<aac003>licong</aac003>
<aac004>2</aac004>
<aac031>2</aac031>`
<pwd>1</pwd>
</resultList>
</return>
</ns2:findPersonListResponse>
</S:Body>
</S:Envelope>
I'm reading the values like this:
dom = DocumentHelper.parseText(result);
Element root=dom.getRootElement();
The root's value is "org.dom4j.tree.DefaultElement#db23f1 [Element: <S:Envelope schemas.xmlsoap.org/soap/envelope/attributes: []/>]".
How do I get the value of tag <aac003>?
Try this expath to get <aac003> value
/*:Envelope/*:Body/*:findPersonListResponse/*:return/*:resultList/*:aac003