Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

java - WSO2 ESB Unable to convert complete JSON data to XML

I am constructing a POC. And I created a pass through proxy service for Google Plus. Without using any proxy service I get this is my output :

 {
   "kind":"plus#person",
   "etag":""ExituU7aUpmkkfyD52VulzptThw/4J1clegrhxYC2fsJOu2XWCs1Ewg"",
   "id":"117488614303967062311",
   "displayName":"Abhi NeoN",
   "name":{
      "familyName":"NeoN",
      "givenName":"Abhi"
   },
   "tagline":"hey guys ! ssup!! check out ma recnt videos... uploaded",
   "gender":"male",
   "aboutMe":"u003cbu003ehie, abhishek - ma full name u003c/bu003eu003cdivu003eu003cbu003em a DANCER ,u003c/bu003eu003c/divu003eu003cdivu003eu003cbu003ei luv ma dancing .u003c/bu003eu003c/divu003eu003cdivu003eu003cbu003ei care ma dancing ,u003c/bu003eu003c/divu003eu003cdivu003eu003cbu003ei jus hv a gr8 thng in me dats ma dancing.u003c/bu003eu003c/divu003e",
   "relationshipStatus":"single",
   "url":"https://plus.google.com/117488614303967062311",
   "image":{
      "url":"https://lh6.googleusercontent.com/-tF-ip0tUxD4/AAAAAAAAAAI/AAAAAAAAAAA/WKI3USUh_DA/photo.jpg?sz=50"
   },
   "urls":[
      {
         "value":"https://plus.google.com/117488614303967062311",
         "type":"profile"
      },
      {
         "value":"https://www.googleapis.com/plus/v1/people/117488614303967062311",
         "type":"json"
      }
   ],
   "organizations":[
      {
         "name":"our lady of nazareth high school",
         "title":"science",
         "type":"school"
      },
      {
         "name":"",
         "title":"BLUEBYTES",
         "type":"work"
      }
   ]
}

But when I try to do the same using a simple pass through service I get only :

{
   "kind":"plus#person"
}

I read on the wso2esb site that they had a bug and the explanation given to resolve the bug was that json data received was not in the proper format. But now how do I resolve the problem. I mean is their any way I can manipulate the json data before the esb converts it into json data.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We have solved this issue in the latest release of ESB (version 4.5.0). By default it comes with JSONMessageFormatter/JSONBuilder that can handle JSON payloads with multiple keys.

We also came up with another solution for handling message flows that involve different types of JSON <--> XML (or JSON <--> JSON) conversions. JSONStreamBuilder and JSONStreamFormatter can be used to implement such scenarios with the 'script' mediator. Have a look at sample #441 in ESB 4.5.0.

To run sample #441;

  • Add JSONStreamBuilder and JSONStreamFormatter as the builder and formatter for JSON in repository/conf/axis2/axis2.xml file
  • Deploy SimpleStockQuoteService
  • Start the sample axis2server
  • Run the JSON client with 'ant newjsonclient'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...