When I print response of the SOAP which has CDATA, it contains gt and lt as shown bellow. Can you please help to convert this to proper xml or can you help me to validate some of the value of the response.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:processRequestResponse xmlns:ns="http://controller.core.xxx.xxxxx.xxxx.xxxxxx.com">
<return><?xml version="1.0" encoding="UTF-8"?>
<xxx:xxxxxxxxxxxx xmlns:xxx="http://xxxxx.com/xxxx/xxxx/xxx/response/xyz/abc">
<Header><destinationId>ABC</destinationId>
..............
..............
...............
</Body>
</xxx:xxxxxxxxxxxxxResponse></return>
</ns:processRequestResponse>
</soapenv:Body>
</soapenv:Envelope>
I think one line will do the trick for you, try this:
* xml temp = $response//return
Related
i am loading the following xml file using the readUrl command
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<a>
<b>xyz</b>
<c>
<d>false</d>
<e>false</e>
<f>true</f>
</c>
</a>
</soapenv:Body>
</soapenv:Envelope>
in the same dataweave as the readUrl command - i would like to update the xml e value from false to true
can someone please assist
cheers,
jonny
Using the update operator available in Mule 4.3.0 can be used to update the value as required:
%dw 2.0
output application/xml
ns soapenv http://schemas.xmlsoap.org/soap/envelope/
var soapMessage=readUrl("...","application/xml")
---
soapMessage update {
case .soapenv#Envelope.soapenv#Body.a.c.e -> true
}
SOAP based XML file :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc" xmlns:cus="urn:com.workday/tenants/super/data/custom">
<soapenv:Header>
<bsvc:Workday_Common_Header>
<bsvc:Include_Reference_Descriptors_In_Response>1</bsvc:Include_Reference_Descriptors_In_Response>
</bsvc:Workday_Common_Header>
</soapenv:Header>
<soapenv:Body>
<bsvc:Edit_Worker_Additional_Data_Request bsvc:version="v36.0">
<bsvc:Business_Process_Parameters>
<bsvc:Auto_Complete>true</bsvc:Auto_Complete>
<bsvc:Run_Now>true</bsvc:Run_Now>>
<bsvc:Comment_Data>
<bsvc:Comment>Test comment on 27 March- attempt2</bsvc:Comment>
</bsvc:Comment_Data>
</bsvc:Business_Process_Parameters>
<bsvc:Worker_Custom_Object_Data>
<bsvc:Effective_Date>2021-03-25</bsvc:Effective_Date>
<bsvc:Worker_Reference bsvc:Descriptor="Employee_ID">
<bsvc:ID bsvc:type="Employee_ID">123</bsvc:ID>
</bsvc:Worker_Reference>
<bsvc:Business_Object_Additional_Data>
<cus:ContractData>
<cus:contractDate>2021-03-23</cus:contractDate>
<cus:wd002AddendumEffectiveDate2>2021-05-23</cus:wd002AddendumEffectiveDate2>
<cus:commissionRates>22.25</cus:commissionRates>
</cus:ContractData>
</bsvc:Business_Object_Additional_Data>
</bsvc:Worker_Custom_Object_Data>
</bsvc:Edit_Worker_Additional_Data_Request>
</soapenv:Body>
</soapenv:Envelope>
C# code:
`ServiceReference1.Edit_Worker_Additional_DataInput data = new ServiceReference1.Edit_Worker_Additional_DataInput(); data.Edit_Worker_Additional_Data_Request.Worker_Custom_Object_Data.Business_Object_Additional_Data.Any=
new System.Xml.XmlElement[] { };`
How to store soap xml file data in "System.Xml.XmlElement[]" array ?
I'm trying to embed a literal CDATA value in a Mulesoft flow and cannot figure out how to do so.
My desired output (in an HTTP request body) is:
<?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>
<query xmlns="http://autotask.net/ATWS/v1_5/">
<sXML>
<![CDATA[<queryxml><entity>ticket</entity><query><condition><field>id<expression op="equals">12345</expression></field></condition></query></queryxml>]]>
</sXML>
</query>
</soap:Body>
</soap:Envelope>
My Dataweave transformation looks as follows:
%dw 1.0
%output application/xml
%namespace soap http://schemas.xmlsoap.org/soap/envelope
---
{
soap#Envelope #(version: "1.0") : {
soap#Header: {},
soap#Body: {
query: {
sXML: "<queryxml><entity>ticket</entity><query><condition><field>id<expression op=\"equals\">12345</expression></field></condition></query></queryxml>"
}
}
}
}
But when I send this request to requestb.in (to inspect the contents), I can see it's coming through like this (focus on the sXML entity):
<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" version="1.0">
<soap:Header/>
<soap:Body>
<query>
<sXML><queryxml><entity>ticket</entity><query><condition><field>id<expression op="equals">12345</expression></field></condition></query></queryxml></sXML>
</query>
</soap:Body>
</soap:Envelope>
How can I get a literal CDATA value in there via dataweave / MEL?
Thank you.
I would try:
sXML: "<queryxml> .... </queryxml>" as :cdata
See https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-formats#custom-types-2 for more information.
handleInteractiveOrder:
write(vars.subm.soap#Envelope.soap#Body.cp#handleInteractiveOrder,"application/xml")
as CData
in mule 4 we can do like this. I kept my XML in subm variable.
I have been receiving the following error when trying to post updated login credentials:
<Exception>org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Can not invoke the getTypeObject method in the extension mapper class...
I am accessing the SOAP API via a rails app using the savon gem.
addItemForContentService is working with the same xsi:type definition, and I have used getLoginFormCredentialsForItem to retrieve FormInfos to push back into updateCredentialsForItem1, with no success.
If I could just get some sample xml (that works) for this call I would really appreciate it.
It seems like the parameters you are sending are incorrect or the WSDL format.
For your reference below is XML for updateCredentialsForItem1(you need to change values):
<?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>
<updateCredentialsForItem1 xmlns="http://itemmanagement.accountmanagement.core.soap.yodlee.com">
<userContext xmlns="">
<cobrandId>134131232</cobrandId>
<channelId>-1</channelId>
<locale>
<country>US</country>
<language>en</language>
<variant></variant>
</locale>
<tncVersion>2</tncVersion>
<applicationId>7A367HGJ621219F00</applicationId>
<cobrandConversationCredentials xsi:type="ns1:SessionCredentials" xmlns:ns1="http://login.ext.soap.yodlee.com">
<sessionToken>YOUR_COBRAND_CONVERSATION_TOKEN_VALUE</sessionToken>
</cobrandConversationCredentials>
<preferenceInfo>
<currencyCode>USD</currencyCode>
<timeZone>PST</timeZone>
<dateFormat>MM/dd/yyyy</dateFormat>
<currencyNotationType>SYMBOL_NOTATION</currencyNotationType>
<numberFormat>
<decimalSeparator>.</decimalSeparator>
<groupingSeparator>,</groupingSeparator>
<groupPattern>###,##0.##</groupPattern>
</numberFormat>
</preferenceInfo>
<fetchAllLocaleData>false</fetchAllLocaleData>
<conversationCredentials xsi:type="ns2:SessionCredentials" xmlns:ns2="http://login.ext.soap.yodlee.com">
<sessionToken>USER_CONVERSATION_TOKEN_VALUE</sessionToken>
</conversationCredentials>
<valid>true</valid>
<isPasswordExpired>false</isPasswordExpired>
</userContext>
<itemId xmlns="">1219123123</itemId>
<credentialFields xmlns="">
<elements xsi:type="ns3:SecureFieldInfoSingle" xmlns:ns3="http://common.soap.yodlee.com">
<name>LOGIN</name>
<displayName>Username</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>2212059</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_USERNAME</value>
<valueIdentifier>LOGIN</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>TEXT</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
<elements xsi:type="ns4:SecureFieldInfoSingle" xmlns:ns4="http://common.soap.yodlee.com">
<name>PASSWORD1</name>
<displayName>Password</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>22121258</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_PASSWORD_VALUE</value>
<valueIdentifier>PASSWORD1</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>PASSWORD</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
<elements xsi:type="ns5:FieldInfoSingle" xmlns:ns5="http://common.soap.yodlee.com">
<name></name>
<displayName>Verify Password</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>22121258</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_PASSWORD_VALUE</value>
<valueIdentifier>PASSWORD1</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>PASSWORD</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
</credentialFields>
<startRefreshItemOnUpdate xmlns="">false</startRefreshItemOnUpdate>
</updateCredentialsForItem1>
</soapenv:Body>
</soapenv:Envelope>
I am invoking the WS using SudzC generated code:
[service createPendingSalesOrders:self action:#selector(handler:) arg0:
#"<?xml version='1.0'"
" encoding='utf-8'?>"
"<root>test</root>"];
The soap request is:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://com/">
<soapenv:Body>
<com:createPendingSalesOrders>
<arg0>"<?xml version='1.0' encoding='utf-8'?><root>test</root>"
</arg0>
</com:createPendingSalesOrders>
</soapenv:Body>
</soapenv:Envelope>
I am receiving:
[com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
from my WS running on glassfish.
The WS works with other XML strings that seem to contain the same PI.
Thanks for any insight,
Dane
If you insist on wrapping xml into xml, put the contents into CDATA section, so the parser would process it as a string.