Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
+1
person also asked this
people also asked this
Replies
9 replies
Subscribers
8 subscribers
Views
4775 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Integrations
Is there a way to parse a SOAP webservice response in an expression rule and pop
soumyab103
over 9 years ago
Is there a way to parse a SOAP webservice response in an expression rule and populate the CDT? For example, my webservice returns response in the following format-
<soapenv:Envelope xmlns:soapenv="
schemas.xmlsoap.org/.../">
<soapenv:Body>
<ns1:getBankResponse xmlns:ns1="
thomas-bayer.com/.../">
<ns1:details>
<ns1:bezeichnung>Aachener Bank</ns1:bezeichnung>
<ns1:bic>GENODED1AAC</ns1:bic>
<ns1:ort>Aachen</ns1:ort>
<ns1:plz>52001</ns1:plz>
</ns1:details>
</ns1:getBankResponse>
</soapenv:Body>
</soapenv:Envelope>
I want to use an expression rule to parse this response and populate a CDT. I used xpathsnippet to parse the above response, but it is throwing-"An error occurred while trying to parse the XML stream".
OriginalPostID-147519
OriginalPostID-147519
Discussion posts and replies are publicly visible
0
travis.blalock
Appian Employee
over 9 years ago
If the XML definition matches your CDT structure you can use the torecord() function to map it directly.
forum.appian.com/.../Scripting_Functions.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
soumyab103
over 9 years ago
Thanks Travis.
I created a very simple CDT: Envelope with just one field: Body, and used the torecord function to populate the CDT with the above SOAP response, but it is throwing the following error- "[Lorg.json.JSONObject; cannot be cast to [Lcom.appiancorp.suiteapi.process.TypedVariable;"
Also, the documentation for torecord method says: type: (Any Type) Enter a variable (process variable or activity class) that has the same data type that you want the XML to be converted into.
In my case, I do not have a process model for this. I simply want to populate my CDT with the response from the above SOAP response. The CDT is expected to have the fields- bezeichnung, bic,ort,plz and the response can return multiple elements with <ns1:details>, so I'll have an array of CDTs.
Thanks in advance.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
venkats533
over 9 years ago
how are you invoking the web service ? how are you providing input to the web service ? once we know the answers to the above, a solution may be suggested.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
soumyab103
over 9 years ago
Hi, I am invoking this web service using an expression rule and using webservicequery method. For example, I created an expression rule with the following contents-
webservicequery(
a!wsConfig(
wsdlUrl: "
www.thomas-bayer.com/.../BLZService
service: "{
thomas-bayer.com/.../}BLZService",
port: "BLZServiceHttpport",
operation: "{
thomas-bayer.com/.../}getBank"
),
{
getBank: {
blz: "39060180" }
}
)
and I want to parse the response of this rule to populate my CDT.
Thanks again.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
venkats533
over 9 years ago
very good. in rule interface test as is and copy the results into notepad to understand the structure of the results returned. Now the results from the web service are already of data type which is auto generated by Appian. Write a simple translation from auto generated CDT to your own custom CDT. In other words, write an expression rule that will take the auto generated CDT as input and returns type!yourCDT(myfiled1: ri!inputCDT.firstName, myfield2: ri!inputCDT.lastName) - thats it - looks simple, unless I have missed something
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
judyg
over 9 years ago
What about accessing directly to your data in this way?
=webservicequery(
a!wsConfig(
wsdlUrl: "
www.thomas-bayer.com/.../BLZService
service: "{
thomas-bayer.com/.../}BLZService",
port: "BLZServiceHttpport",
operation: "{
thomas-bayer.com/.../}getBank"
),
{
getBank: {
blz: "39060180" }
}
).returnValue.getBankResponse.details
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
venkats533
over 9 years ago
Judy, error conditions need to be considered as well. in case there is a fault, getBankResponse may be empty, hence .details will cause a scripting error
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
judyg
over 9 years ago
You are right. Need to double check if getBankResponse returns an empty value or a null value. If it returns a null value, the .details will cause error, if it returns an empty value, the details will contain empty data.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
soumyab103
over 9 years ago
Thanks venkats533 and judyg . It worked. Really appreciate your help.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel