ByteBuf with JSON? - http

I am a student who just started using Netty!
I am building a server that communicates with android and iOS. The primary task of my server will be sending and recieving JSON files with images(10 jpegs) and texts(less than 100 character).
My server's framework is Netty.
I built my server from "HttpUploadServer" from the Netty 4.0.6 example jar. As my server's primary task is to upload and download JSON files, I only used multipart POST part from the example.
So here is my question.
Netty's HttpRequestEncoder and HttpResponseDecoder turns Http requests into ByteBuf and ByteBuf to responses.
However, what happens when I try to communicate with JSON? Does the encoder and decoder turn JSON into a ByteBuf and sends it?
What is the normal way Netty users send and recieve JSON through HTTP?

For sending and receiving JSON messages, you don't need to add any Handlers. Http Encoders/Decoders are enough.
Here is a example that uses JSON to send and receive.
http://kevinwebber.ca/multiplayer-tic-tac-toe-in-java-using-the-websocket-api-netty-nio-and-jquery/
Regards,
Rama Krishna.

Related

Sending Image And Metadata Using Restful - JSON

I am bit new to HTTP/2. I have learned that using HTTP/2 we can send multiple requests to the server without waiting for previous responses. Well I want to send an image file to the server which is large (more then 500 MB). There are following ways as listed here
Base64 encode the file, at the expense of increasing the data size by around 33%.
Send the file first in a multipart/form-data POST, and return an ID to the client. The client then sends the metadata with the ID, and
the server re-associates the file and the metadata.
Send the metadata first, and return an ID to the client. The client then sends the file with the ID, and the server re-associates
the file and the metadata.
I donont want to use first solution because it will increase the file size by 33%. I want to use 3rd solution.
As I am using HTTP/2 so my questions are
Can I send metadata and image simultaneously without waiting for ID from the server ?
If yes, then how can I implement ? Like do I have to do multithreading at server end for a client or how can I associate metadata and image with each other ?
If no then should I go for conventional style of HTTP/1.1 ?
I am using Restful and JSON for communication. More specifically I am using C# command-line client to send image and Asp.Net as server.
You can use multipart/related type to make a request with related mime-types. i.e in your case you can send an image along with a JSON body data.
You can refer Google drive file upload api which has a very similar implementation.

Third party to PeopleSoft SSO integration

I have to write sign on peoplecode to make a service call by passing token (sent from third party) to API and get the responce (if token is valid responce will have username) in json format to create a PS_TOKEN.
I am fresher to peoplecode. How can I run HTTP POST request by passing token and get the response using Peoplecode?
You would create a synchronous service operation in the Integration Broker. The Integration Broker works best if you are sending XML or JSON. If this is just a regular HTTP POST with fields then it can cause some issues with the Integration Broker. I had a similar case and could not get the basic HTTP Post to work but instead ended up using HTTP POST multipart/form-data and was able to get that to work.
Steps I had to do to make this work.
Create a Message (document based or rowset based are both possible)
Create Service Operation and related objects
Create Transform App Engine to convert the Message to a HTTP POST multipart/form-data
Create a routing and modify the connector properties to send the content type of multipart/form-data. Also call the Transform app engine as part of the routing.
The issue with a application/x-www-form-urlencoded POST is that it seems PeopleSoft does another url encoding after the Transform, which is the last time you can touch the output with code. This final url encoding was encoding the = sign in the form post which made the format invalid.
Your other option would be to write this is Java and call the Java class from within PeopleSoft (or mix the Java objects in with PeopleCode). If you choose to go this way then the App Server needs to have connectivity to your authentication server. My only experience with this is I had a client that used this approach and had issues under heavy load. It was never determined the cause of the performance issue, they switched to LDAP instead to resolve the issue.

Partial Response received from Apigee

The flow is SAP NWAS 7/Java AS ---> Apigee On Premise--->Apigee OnCloud -----> Backend. and back.
Backend is posting a response of appx 17 MB back. I have streaming enabled both on cloud and on premise Apigee. But the sap NWAS client states that only partial response is received .
When we invoke from POSTMAN however, we are getting complete response.
Please suggest where the problem can be?
Since Postman works fine for you, it seems like it might be a problem on the client side. So, it's possible that the client requires more info on the response in order to be able to display the content e.g. Content-Type header. Another way to troubleshoot this issue is to send a cURL command to the resource in Apigee and store it in the filesystem to validate that not only Postman can parse the response. e.g.
curl http://yourresourcehere/images/12344 > img12344.png

Read RSS feed with Biztalk

Is it possible to import the contents of an RSS feed with Biztalk?
I would like to import the RSS feed and send it to a Send port that put the content into a SQL Server database.
Thanks
You will need to start with an Xml Schema (XSD) that defines the RSS message - take a look at http://rss2schema.codeplex.com/ which defines an RSS 2.0 schema.
You would typically retrieve an RSS feed from a HTTP endpoint by issuing a HTTP GET request and the webserver would respond with the RSS content.
Unfortunately, the BizTalk HTTP Send Adapter (the thing that performs the HTTP request on your behalf) only supports the POST verb and I imagine you will find that the majority of websites won't let you retrieve an RSS feed by using POST.
There does appear to be a few options out there, including using a WCF-Custom Send Port (http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/3d001f89-88e2-4c67-8a54-2ea5a5f7c064/). If this seems like a lot of work, you might simply want to consider writing a WCF Service or Web-Service which would perform the GET Request which you invoke from BizTalk.
Once you have the RSS response message, simply parse and write to SQL using a Send Port configured with the SQL Adapter (or WCF-SQL Adapter).
I imagine that the lack of HTTP GET in the BizTalk HTTP Adapter is why nsoftware wrote its RSS adapter....
Since rss is basically an xml message, and BizTalk provides an HTTP protocol, it would seem reasonably simple.
Create a receive location to retrieve the rss feed
use an orchestration to load the content
Create a send port to connect to sql server to write the content you retrieved.
It's not trivial, but doesn't seem too difficult

Does REST send its payload in the URL of the request? What about SOAP?

Do SOAP and REST put their respective payloads as a URL? For example:
http://localhost/action/?var=datadatadata
I know SOAP uses XML and sometimes runs on a different port on the server, but do you still submit data like the example above or do you send it as one big XML encapsulated packet to that port?
It depends on your HTTP method. GET method will put everything into URL while POST method only put path information in URL and the rest of them are streamed into the HTTP request body.
SOAP should also rely on HTTP protocol and hence should follow the same rule. Check out http://www.w3.org/TR/soap12-part0/#L10309

Resources