Parsing MuleSoft CXF Request - java

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>

Related

Axis 1.4 - Enable MTOM

I am working on a web service project that uses Axis 1.4. The stub and classes are built from the Eclipse Generate Client tool and a provided WSDL. I am able to upload files without issue but I am unable to download files. Requested files are sent back using MTOM. My Request and Responses are formatted correctly but I am getting the following error:
Axis Fault string: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
I have set the following but it does not appear to help:
getStub()._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,Call.ATTACHMENT_ENCAPSULATION_FORMAT_MTOM);
Any help would be great appreciated on how to resolve this and be able to access the attachment.
Request:
<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>
<getFile xmlns="endpoint">
<input>
<userName>USERNAME</userName>
<passWord>PASSWORD</passWord>
<fileName>FILENAME</fileName>
</input>
</getFile>
</soapenv:Body>
</soapenv:Envelope>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<getResponse xmlns:a="http://www.w3.org/2005/05/xmlmime" xmlns="endpoint">
<output>
<fileData>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:FILEREFERENCENUMBER#apache.org"/>
</fileData>
</output>
</getResponse>
</soapenv:Body>
</soapenv:Envelope>

Send Soap Request in java with Authentication

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

How to parse soap response from web service to get value of node using java

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>

jax-ws webservice client returns only empty objects

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.

SOAP Request using Java

I have been trying to send a request through soapui and I always keep getting the following error message:
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Failed to process SOAP request. SOAP body not in UTF-16.</faultstring>
<detail>
<wsdl_ops:error>
Failed to process SOAP request. SOAP body not in UTF-16.
</wsdl_ops:error>
</detail>
</soap:Fault>
</soap:Body>
Has anyone run into the same issue before?
UPDATE:
I changed the encoding to UTF-16 and it worked for me. Now, when I send the request I get the following error instead:
REQUEST:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.broadsign.com/wsdl_ops">
<soapenv:Header/>
<soapenv:Body>
<ns1:request not_modified_since="1970-01-01T00:00:00" token="0" requestid="1" version="4" name="category_mgr_list">
<category domain_id="1719213" />
</ns1:request>
</soapenv:Body>
</soapenv:Envelope>
RESPONSE:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl_ops="http://www.broadsign.com/wsdl_ops">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Invalid request.</faultstring>
<detail>
<wsdl_ops:error>Invalid request.</wsdl_ops:error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What am I missing? :(
Sounds like the service is expecting the request to be encoded as UTF-16. Validate your request and try setting the encoding in the request properties. Failing that, edit your question with the raw inputs and outputs.

Categories

Resources