SOAP service crash with empty field in request - web-services

Our SOAP web service provider insist on removing empty field tags from the request because it breaks the service. Is that right practice?
See below example of request. StockID is empty tag. Should it break the SOAP service?
I would like to know best practice around empty tags in request
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
<m:StockID/>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

This Depends on how the rest of the system is programmed. There are 3 ways of sending StockID:
Empty tag
Tag removed
Tag With nil="true"
What is probably happening for the first item above is that the program is deserializing the tag as an empty string, and then crashing since there is no Stock id = "".
In the 2 last items above it would deserialize as NULL and then not try and find a Stock id = NULL.

Related

Including a CDATA field in a Service Connector

An API I am communicating with is Soap based and requires XML with inner XML (CDATA) in the request.
For the service connector action test I have hard-coded the inner xml with this format:
<![CDATA[
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationCrossReferenceId="123">
...
...
</Application> ]]>
where the dots indicate the data contained.
When running the test the request payload has been transformed to the html entity for < which is $lt; - as seen below :
Is there a way to avoid this?
This is a bug in Informatica. the other characters are decoded back to their original correctly, as described in KB 512858, &gt and &lt however are not decoded.
A bug report has been raised 29.05.2020.
Edit: Further investigation revealed that using CDATA was not necessary in my case, instead I was able to use the following input for the body binding:
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationCrossReferenceId="123">
...
...
</Application>

Addressing an xml value in enrich Mediator

I want to address an xml value in the Xpath field within the enrich mediator in order to customize an API response. My xml input is as follow:
<member>
<name>ABC</name>
</value>1</value>
</member>
I tried to access the 'ABC' value by using this code:
$body//member[#name='ABC']
but it does not work for me.
First of all your XML input is not valid. There is no opening value tag but two closing.
Can you try //member/name/text(),this worked für me.If its not working,then maybe you need to add the namespaces.
Hope that helps.

Twilio + Django - Voice message

Here's my requirement:
I have a text ="Thank you for your response". I want to initiate a call with a user, and when the user picks up the call, i want the text message to be turned into a voice message.
Here's what i have so far:
I am initiating a twilio call:
twilioClient.calls.create(to=user_number, from_=twilio_number, \
url="https://testserver.com/call/")
In urls.py, i have /call/ that points to my django view module
In view, the module looks like:
def testTwilioCall(request):
return HttpResponse(open('/path/call.xml').read(), content_type='application/xml')
-call.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="woman">Thank you for your response.</Say>
<Record maxLength="20" />
</Response>
Here's whats happening:
User gets a call, and the call says - "Sorry application error".
I am not sure what is going wrong. When i replace the url parameter with https://demo.twilio.com/welcome/voice/, it works.
I also double checked that the xml is being displayed fine from the browser.
Not sure where i am going wrong with rendering the xml.
PS: testserver is just a placeholder.

SoapUI how to check the count of number of items returned in response

is there is way to check the count of the items returned. basically I have a soap service which can return list of data items, is there an easy way to have an assert statement to check the count of the list? tried groovy script but didn't have much luck
You can add and assertion of XPath Match type in your testStep, and there check the condition. i.e you have a response similar to:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<myRoot xmlns:nt="http://mynamespace/">
<list>
<element>data1</element>
<element>data2</element>
<element>data3</element>
</list>
</myRoot>
</soapenv:Body>
</soapenv:Envelope>
Then add in your assertion the next XPath count(//*:myRoot/*:list/*:element) and set the expected result, in this case 3:
Hope this helps,
Yes. You can create a XPath Match assertion. Use the count() function.
There is a website that is a nice reference for all the XPath functions: http://zvon.org/comp/r/ref-XPath_2.html#Functions~count

Sending a SOAP Call

I'm learning how to send and receive a SOAP call. I have the required parameters available with me like username , password and the URL of the WSDL/WebService.I lso know a sample SOAP reply that I'm expecting which is as follows:
<?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/">
<SOAP-ENV:Body>
<ns1:infoLookupResponse xmlns:ns1="urn:vtsPhoneNumberLookup">
<phoneNumber xsi:type="xsd:string">4444444444</phoneNumber>
<Type xsi:type="xsd:string">Landline</Type>
<OCN xsi:type="xsd:string">2222</OCN>
<OVERALLOCN xsi:type="xsd:string">2103</OVERALLOCN>
<COMPANY xsi:type="xsd:string">ABC Inc</COMPANY>
<DBA xsi:type="xsd:string">ABC Inc</DBA>
<CommonName xsi:type="xsd:string">ABC</CommonName>
<HOLDINGCOMPANY xsi:type="xsd:string">ABC Communications Inc</HOLDINGCOMPANY>
<MANAGEMENT xsi:type="xsd:string"></MANAGEMENT>
<SMS xsi:type="xsd:string"></SMS>
</ns1:infoLookupResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I have gone through online stuff and based on my understanding, in order to send the SOAP request, I need to have a raw XML of the same format that I'm
expecting ( as mentioned above). The condition in my case is that a user will be submitting a phone number using an HTML Page and that will be sent as a SOAP
request expecting the aforementioned reply from the server.
In the above case, a user would have submitted 4444444444 as a phone number. So,I understand that I need to create raw XML type of phoneNumber and my questions is, do I need to create raw XML for Type,OCN,OVERALLOCN,COMPANY,DBA,CommonName,HOLDINGCOMPANY,MANAGEMENT and SMS as well?
Please let me know if there is anything wrong with what I have understood so far. Also, let me know if you would like me to paste some specific part of WSDL which will help you in answering/understanding my question.