Questions regarding XML request format - web-services

Please consider the following code from Ben Nadel's post:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Subscriber.AddAndResubscribe
xmlns="http://api.createsend.com/api/">
<ApiKey>#campaignMonitorKey#</ApiKey>
<ListID>#campaignMonitorList#</ListID>
<Email>kim#sweet-n-sassy.com</Email>
<Name></Name>
</Subscriber.AddAndResubscribe>
</soap:Body>
</soap:Envelope>
I understood that AddAndResubscribe is the operation name and Subscriber.AddandResubscribe is the input name. I am wondering what does campaignMonitorKey, campaignMonitorList , the value in the Email tag and an empty Name tag means? Could anyone please explain?
Source for WSDL: http://api.createsend.com/api/api.asmx?WSDL
Source for the POST: http://www.bennadel.com/blog/1809-Making-SOAP-Web-Service-Requests-With-ColdFusion-And-CFHTTP.htm
Thanks

In Ben Nadel's post, he's sending data to Campaign Monitor's newsletter subscription API. The structure of the soap body is dictated in this case by Campaign Monitor. What is being passed are the values needed to use their addAResubscribe method.
Since I don't use Campaign Monitor, I'm only making an educated guess here:
ApiKey: I'm assuming is an authentication key you gain when you sign up. This allows Campaign Monitor know who is sending the request, and that the customer is still active. Notice that #campaignMonitorKey#. This value would be set else were in the application. Since it's Ben's ApiKey, the setting of this value was left out of his example.
ListID: would be the ID representing a mailing lists. Once again, this would be set else were in the application, and wasn't shared in the example.
Email: the email being added.
Name would be the name of the person reviving the email.
When consuming soap request myself, I first use an application called SoapUI. This tool can generate sample request bodys for all the methods exposed by the WSDL URL. From here you can try putting in your own values and get a response back.

Related

How to use the url that came in response

Help to understand and direct what needs to be done further. I use the robot framework version 3.1.1 and the Python 2.7 programming language to write the autotest script, and now there is a task to develop a test that will work with POST / GET requests. So, I make a POST request to the system to initiate a payment. The answer comes that the payment has been created, but for all actions it is necessary to follow the link inside the answer.
Request:
Create Session allias URL
&{params}= Create Dictionary params1=value1 params2=value2
${resp}= Post Request allias /init_payment.php params=${params}
Should Be Equal As Strings ${resp.status_code} 200
Reply post response:
<?xml version="1.0" encoding="utf-8"?>
<response><pg_status>ok</pg_status><pg_payment_id>3016695</pg_payment_id><pg_redirect_url>https://test.paybox.money/payment.html?customer=028c44bf25b6be251199221d04b570c2</pg_redirect_url><pg_redirect_url_type>need data</pg_redirect_url_type><pg_salt>8OYUsodtnaTWKbOD</pg_salt><pg_sig>a26e61d6eb710c430d67150498d1f555</pg_sig></response>
How to show the framework so that it can go through the redirect url? I would be very grateful for your help.
The RequestsKeywors from the Robot Framework use Requests HTTP Client. Reading the quickstart from this library you can find that the response's contents is available in the text field.
${body}= ${resp.text}
Then you'd most likely want to parse the XML. You can use the XML library for that.
It will be something like
${root} = Parse XML ${body}
${link} = Get Element Text ${root} response/pg_redirect_url

How to access twilio's request from the aws api gateway mapping template?

I want to access my twilio get request (body, method, query etc.) via the aws api gateway but i don't know what to put in my aws api gateway in the mapping template to process it.
Any help will be highly appreciated.
Thanks.
If you want the response from the endpoint to be passed through as-is, you can use pass through mapping. Otherwise, you can use the mapping templates to customize the method response. Here is the Mapping Template Reference for API Gateway. Please let us know if you have any specific questions.
This is the most complete answer for AWS API Gateway to convert a form URL encoded POST, to a JSON payload...
Convert URL Encode to JSON NOTE: Scroll down to the last answer, as there are several updated to account for edge cases.
It's a lot of ceremony, using a language that I've never seen before, but at least it's readable. Far cry IMO from Azure functions where you simply get the request, and then manage it with the language that you are in.
This only gets you half way there however, you also have to add a mapping template to the Integration Response - but that template is simple and is referenced in the previous comment - repeated here for convenience
#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<Response>
$inputRoot
</Response>
Since I'm using only responding to an SMS message - I added the following, and only returned a string from the function:
#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>
<Body>
$inputRoot
</Body>
</Message>
</Response>

Can I use the Key field in NAV table records the way I want to in an XMLPort?

Specifically in NAV 2013. When I look up a record using a Page webservice, I get a response something like the following:
<Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/soap/envelope/">
<Soap:Body>
<ReadMultiple_Result xmlns="urn:microsoft-dynamics-schemas/page/[PAGENAME]">
<ReadMultiple_Result>
<[RECORDNAME]>
<Key>##;[KEYSTUFF KEYSTUFF KEYSTUFF];[OTHER KEYSTUFF];</Key>
<[OTHERFIELD]>[OTHERDATA]</[OTHERFIELD]>
</[RECORDNAME]>
</ReadMultiple_Result>
</ReadMultiple_Result>
</Soap:Body>
</Soap:Envelope>
... and then, if I want to interact with that record to do an Update or Delete through the webservice, I have to use the Key field to refer to it directly.
What I want to know is if I can expose an XMLPort through a Codeunit webservice, and still export that Key field directly, or if I'll have to do some separate lookup to add it to the export for each row? Or if it might just make more sense to expose this info as a page since I'm planning on interacting with the records?
In this question a guy states that
that at least part of the key is a Base64 encoded string of the columns that make up the primary key
so the first part of the key is some kind of salt or timestamp that is used to avoid overwriting record when updating through exposed page.
There is no function in Nav that allows to calculate web-service key for certain record and no way to use this key in C/AL to fetch record.
If your intention is to use exposed codeunit to both read and write you can use XML port with Direction property set to Both as the parameter of procedure to read and update record in certain table(s). Of course in that case you have to use all primary key fields in XML Port to identify record.

SOAP Request from Siebel has namespace in every element

In an outbound webservice, I am trying to send a request to another application. Problem is when Siebel sends the request, it is sending namespace parameters in every element of the soap request.
See Below:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body><getAuths xmlns="http://data.service.client.ods.transys.wex.com/">
<authSearch>
<authID xmlns="http://data.service.client.ods.transys.wex.com/"></authID>
</authSearch>
</getAuths>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Whereas If I am trying the same request from SOAP, there is no issue in the SOAP XML that is sent.
I checked a similar blog earlier where there is some name space property to be removed from Integration Object, but I am not able to get rid of the problem.
Can anyone tell me if the IC Field USer property has to be altered or IC User prperty or the IO user property?
Any response for this will be highly appreciated.
Thanks in advance. !
Best Regards,
-N
The IC field user propery has to be retained, do not inactivate it. Instead, delete the text in the value field next to it.
So you will have ICField user property, but blank. This should remove the namespaces.
If this does not work, try inactivating all the IO and ICF user properties which has namespaces in them.

WSO2 ESB Aggregate from different responses

I am bit confused with WSO2 ESB aggregator mediator.
I need to send three messages to different systems via WebServices, but the three systems have different message formats, so i need to transform each response to canonical model before validate onComplete expression, how can i achieve this?
Thanks for your quick response!
I know that XSLT transformation is what i need to transform the response message, but the problem is i don't know where to put it. What i understand is the onComplete section needs a xpath expression from response message, but the three message have different xpath values.
for example:
Response 1:
<ns:getCustomerInfoResponse>
<ns:Status>
<ns1:Code>0</ns1:Code>
<ns1:Desc>SUCCESS</ns1:Desc>
</ns:Status>
</ns:getCustomerInfoResponse>
Response 2:
<v1:findByIdResponse>
<output>
<StatusCode>0</StatusCode>
<StatusDesc>OK</StatusDesc>
</output>
</v1:findByIdResponse>
What i need is transform two (or three) responses to unique canonical response before validate onComplete expression to something like:
<ns:response>
<status>
<code>0</code>
<desc>SUCCESS</desc>
</status>
</ns:response>
Thanks.
Thanks Ratha for your response.
Consider the following scenario:
In a bank there are three different systems: Credit System, CoreBanking System and CRM system.
I need to do something like "get all balances from all products", so, the request is the customer id, then the customer id is sent to CRM for obtaining all customer products. Depending of the product (Credit Card or Savings Account) it needs to send the customer id to Credit System or CoreBanking. Finally, each system will response and the ESB needs to response with both balances.
Hope you can help me with this use case!
Regards.
I don't think it is right to use aggregate mediator here, since you are receiving different responses from the service endpoints, which can not be correlated using xpath.
Aggregate mediator, which can be used along with clone/iterate mediators. Clone and iterate mediator is used to send same requests to multiple endpoint/such like scenarios.
My questions;
Are you sending same request to different endpoints and which are responding different type of responses? If so, it looks bit wrong, how you defined your services.
If you are sending different requests and getting different response, and want to aggregate( or create a new reponse) based on the responses which you received from your backend services, it will fall into service chaining pattern, which you can find in the ESB documentation.
Hope this is clear to you.
You can use XSLT mediator to get messages in to a unified format. please refer [1] for the XSLT mediator sample.
[1]. http://wso2.org/project/esb/java/3.0.1/docs/mediators/xslt.html
Thank You,
Dharshana.
This blog also explains your scenario with a sample...
If I understand you correctly, you want a combination of service chaining, transformation and iteration/aggregation.
So you start by sending the request to the CRM System, it will then respond with the different products, subdivided into Credit Card or Saving Account.
Then you could use two iterate mediators to split the response into the different requests for the two endpoints and collect the responses by using the aggregate or property mediator in the response sequences.
Now that you have the responses of the Credit System and CoreBanking service, you can start to transform (XSLT) and aggregate them to your response (balances).
Here you can find an example for service chaining and a bit of XSLT transformation.
Regards.