In my store, I need to build Soap API, which accepts XML data from 3rd party solution, parses it and creates new customer based on provided data.
My questions is how can I get XML from post body data?
Thanks!
Just don't. Create separate service that is going to do that using Magento framework (check Customer or Catalog module for guidance). Because your request at the moment looks like you're going wrong way.
Just capture the XML in Controller's execute function.
Related
I don't mind if you use an example from another API that is not Adobe Analytics'. I just need to know the pattern that I have to follow in order to succesfully convert a Postman request into a NiFi request.
After successfully creating requests to pull reports from Adobe Analytics via Postman, I´m having difficulties to migrate these Postman requests to NiFi. I haven´t been able to find concrete use cases that explicity explain how to do this kind of task step-by-step.
I'm trying to build a backend on top of NiFi to handle multiple data extracts from Adobe Analytics in an efficient and robust way. That is instead of having to create all required scripts by myself. Yet, there is more documentation about REST APIs and Postman cases than there is about REST APIs and NiFi cases.
In the screenshot below we can see how the Postman request looks like. It takes 3 headers and 1 temporary header that includes the authorization value (Bearer token). This temporary header is generated automatically after filling in the OAuth 2.0 authorization form in the Authorization tab, as shown here.
Then, we have the body of the request. This json text is generated automatically by debugging Adobe Analytics' workspaces as shown here.
I'd like to know the following in a step-by-step manner with screenshots if possible:
Which processor(s) should I use in NiFi to obtain a similar response as the one I got in Postman?
Which properties should I add/remove from the processor to make this work?
How should I name these properties?
Is there a default property whose value/name I should modify?
As you can see, the question mainly refers to properties setup in NiFi, as well as Processor selection. I already tried to configure some processors but I don't seem to get the correct properties setup, or maybe I'm selecting the wrong processors.
I'm using NiFi v1.6.0 and Postman v7.8.0
This is most likely an easy task for users already familiar with NiFi and API requests, but it has proven challenging to me. Hopefully this will help other users looking to build more robust pipelines by using NiFi instead of doing it manually.
Thanks.
It only takes 3 NiFi processors to replicate a REST API request that works in Postman. In this solution we use a request that contains a nested JSON request. The advantage of this simple approach is that it reduces the amount of configuration required to obtain a successful response from the API. That is, even if you are using a complex JSON request. In this case the body of the JSON request is passed through the GenerateFlowFile processor, without the need of any other processor to parse/format the request.
Step #1. Create a processor called GenerateFlowFile. The only property that you will have to modify is the Custom Text. Paste in there your whole JSON request just as it was in Postman. In this case I'm using the very same JSON shown in the question above. It's a good idea to setup Yield Duration to 10 seconds or more.
Step #2. Create a processor called InvokeHTTP. Then modify the 6 properties shown in the screenshots below. Use the same Authorization details you've used in Postman. Make sure to copy the Bearer token from Postman after it has been tested. Also, don't forget to setup the HTTP Method, Remote URL and Content-Type as well.
Step #3. Finally, add a couple of LogAttribute processors to store the output of InvokeHTTP. One of these LogAttribute processors should store successful responses. The other one can be used for Failure, Original, Retry and No-Retry. Or you can create LogAttribute for each of these outputs.
Step #4. Now, connect the processors and Start your data flow! You should start seeing data populate the Successful LogAttribute. Then you can use the Data Provenance option to review the incoming data and confirm that this is exactly the same result you previously obtained from Postman.
Note: This is a simple, straightforward, "for starters" solution to replicate a Postman API request using a nested static JSON. There are more solutions in StackOverflow that tackle more complex cases, like dynamic JSON. Here's a list of some other posts:
nifi invokehttp post complex json
In NiFi processor 'InvokeHTTP' where do you write body of POST request?
Configuring HTTP POST request from Nifi
I am Working on yforms with Hybris 6.5.
Currently I have created forms. After clicking on save button, data is getting saved in my database. Now I am facing problems for:- 1) Fetching the data by fields (as they are in form). 2) Sending that data to any third party apps
In Hybris , they are using hybris database as persistence API for orbeon form. So the orbeon form data will be stored and retrieved from hybris database. Coming to your issues ,
1) whole xml data will be stored as String . So its not possible to get the particular field separately by getter/setter. But you can parse the whole xml string using some xml parser and get the field you want.
2) There are two ways , you can do it . One is directly from Orbeon forms, sending the submitted directly to some controller and from there parse the data and send to the 3rd party or any other action you want to do . Another way is writing an interceptor in hybris for yformDataModel and do your action . I would prefer thge
There are 3 main ways for you to access the XML data captured based on the answers provided by users to your forms:
You can setup Orbeon Forms to send that data to a service you provide when users submit the form.
You can call a REST API provided by Orbeon Forms to access the data it stored in the database.
You can access the database directly.
For more on this, see Accessing Data.
I am very new to the pentaho data integration tool.
I want to consume a restful service(post web service) from my pentaho. For that i found that i should use a rest client. But when i give the url and body(as i want to consume post service) it is not making the necessary changes in the database.
Can anyone tell me how to give body in the rest client in pentaho? i suspect that there is some different way to give the body in the body field of rest client.
I am attaching the screenshot of the rest client which i am making.
Also can anyone suggest me some good links where i can find tutorials for pentaho.
In PDI, you need to receive rows, and process them in the next step.
For this case, as stated in the forum, you first need the "GENERATE ROWS" step, to make at least one call to the REST webservice.
Remember to generate only 1 row, else, you will make a X number of calls to the REST webservice.
Then, in the "REST CLIENT" step, choose the field that is generating the row with the URL in the attribute "Accept URL from field".
Hope it helps.
Use Generate Rows for your url then pass that to the REST Client and use the 'Accept URL from field'. That's the only I found it to work.
I'm new to REST APIs and trying to understand the basics of them. So lets begin by saying that I have created a simple CMS web application using PHP (You create an user, you post an entry and assign some categories maybe, etc...).
That being said, if I wanted to create a mobile app that would do the same, I'll have to create some PHP functions in order to send data as JSON or XML and also in order to process a POST or PUT request.
is a REST API the collection of those functions I'd use to handle the mobile app POST, PUT and GET request using JSON or XML as the data format? if not, can I get an example, not a definition, please.
To answer your question,yes, the REST API is a collection of those functions for any client you wish to expose it to for creating an user, posting an entry etc. The accepted data format is something you decide for your API. It may be JSON, XML or even both.
Some examples:
http://coenraets.org/blog/2011/12/restful-services-with-jquery-php-and-the-slim-framework/
http://peter.neish.net/building-a-mobile-app-backend-using-mongodb-and-slim-a-php-rest-framework/
I have implemented a REST based web service and used it to access data back in MySQL database.
I am using this framework to access the json data http://code.google.com/p/json-framework/
I have no problems in getting the content from this web service, but how can I put something in the database? Should I just make a special query string and have the php code in the backend to interpret this special keyword/query string as an insert to the database?
You're looking for ASIHTTPRequest. You can use that for everything from dumping pages to submitting data via POST or FORM.
Have fun :)
POST is a HTTP method. Your web service should behave differently depending on the method used for the request, if you're implementing REST.
If you send a POST request, your web service should inspect the parameters and do what it needs to do.
What parameters you send and how is dependent on how you've written the web service. Ie. Is the web service expecting XML requests or JSON or URL parameters?