How to extract query parameters for a POST request in the sample aws in tutorial

Not applicable

I am trying to create a proxy by following the tutorial. I have selected Type as "SOAP Service", in the details window I have selected the WSDL from the example URL.

http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

It contains some Post methods, I want to hit those methods and get the response. But not sure how to frame the Post request for this service.

If it is a GET call, we can identify the resource path from the flow and the query parameters from the "Extract Variables" policy. But I need these kind of information for this service.

In short, I need to frame the POST request for the sample Amazon WebService available here.

0 10 3,174
10 REPLIES 10

Hmmm, I'm not clear on what you're asking.

I think you want to proxy requests to the AWS Ecommerce Service, as defined by the WSDL you cited.

What do you want the proxy in Apigee Edge to do? Can you show me

  • the desired inbound message to Apigee Edge
  • the desired outbound request message that you want Apigee Edge to send to AWS?

BTW, here is a tutorial on how to build an API proxy that connects to a SOAP backend. Maybe helpful. It shows you how to create a SOAP message to be sent to the backend, using query parameters sent in the inbound request.

If that doesn't resolve your question, please provide more details.

Hi Dino, Thanks for your reply. That AWS has some POST methods like cartcreate and cartadd.

To call these methods the URL would be something like " https://palanichamyk-eval-test.apigee.net/awsecommerceservice/cartcreate".

But from where I can get the query parameters if any. From where I can get the exact SOAP request including header, payload, etc., for POST request.

When I click the "cartcreate" flow in the developer panel, it has three policies associated with that and none of them have business terms.

6601-cartcreate.png

6602-cartcreate-requet.png

If it is a GET call, then I can use Extract Variable policy to get the query parameters.

hi Karthikeyan

from where I can get the query parameters if any. From where I can get the exact SOAP request including header, payload, etc., for POST request.

The problem with the WSDL Import Wizard is that you do not have control over which operations turn into GET and which turn into POST. The WSDL Import decided to map the cartcreate operation to a POST.

You may wonder: "what jsOn do I need to send into that thing?" and I don't have a clear answer for that. It depends on the XML that the SOAP message requires. you can see one of those policies is a JSON-to-XML mapper. And so the JSON you need to send in with that POST is the JSON that would result in the right XML for the backend service, when mapped through the JSON-to-XML policy. That's an indirect answer, and I'm sure not satisfying, but that's all I can tell you. If you like, you could experiment with various JSONs and using Trace, see what gets generated, to determine the right input.

What you seem to desire is that the cartcreate method gets mapped to a GET call. My response to that: First, that's not a good idea. HTTP says that the GET verb is intended to be idempotent. Creating a cart is not idempotent. The natural thing to map cartcreate to is a POST. So please don't try mapping it to GET; it does not make sense to do so.

HTTP GET is by definition a read operation - it causes no change in the server.

cartcreate is not that. It should be mapped to an HTTP Verb that implies "update the server". And POST is that verb.

OK, suppose you don't like my advice here (really you should not disregard it), and you still want to map cartcreate to a GET. How can you get the right query params?

I suggest that you follow the approach I took in the screencast I referenced above. For this to work you need to know what the backend is expecting for cartcreate. Then use AssignMessage and reference request.queryparam.XXXX for whatever query params you want to substitute into the SOAP payload.

But don't do this. It's a bad idea. Nonsensical.

Don't use GET for updates.

Hi Dino, cartcreate is a POST call and I am struggling to frame the input SOAP request for this POST call. That is the issue I am facing.

Not only with this Amazon Web Service, in general any web service hosted in Apigee, if I am not the developer of those services, Is there any way to identify the request template for the services?

Else, can I download the WSDL of the services deployed in apigee? If I get that I can frame the POST request by analysing the WSDL.

I am not the developer of that API and I don't have the WSDL of that service. But still I want to hit the service with the proper POST request. Is this possible in Apigee?

@karthikeyan

Even I faced the same issue. I tried to import a WSDL which eventually had a POST request method after importing the WSDL in apigee and I was not sure of what should be the POST request Body .

Were you able to solve the above scenario for POST request body. If yes, can you please share the steps you employed to get the perfect response .

Thank You

Try loading the WSDL into SOAP-UI. It will give you an example request.

> Not only with this Amazon Web Service, in general any web service hosted in Apigee, if I am not the developer of those services, Is there any way to identify the request template for the services?

The request is defined by the WSDL. If you can interpret WSDL by sight, then you yourself can create the request template. But I suggest you use a handy SOAP-oriented tool like SOAPUI to see the example request messages that correspond to each SOAP operation.

Thank you Dino for the reply. But what if I don't have the WSDL itself? My objective is to analyse the already deployed proxy. So, is there anyway to download the WSDL from the apigee dashboard? If I am able to get the WSDL, I am sure I can frame the request

Hi Karthikeyan - unfortunately when using the WSDL import wizard in Apigee Edge, the original WSDL is not preserved or retained. You cannot un-bake that cake. You'll need to obtain the source WSDL elsewhere.

Hi Dino, Is there any possibility to implement that functionality in WSDL import wizard? Like, to preserve or retain the WSDL and that can be available for download. So that by using that WSDL, we can frame the request.