I'm in a job of converting a restful webservice to soap. Tool for convertation uses XQuery.
Now i need to convert a message like this:
{
"firstName": "John",
"midName": null,
"lastName": "Smith",
"married": false,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [ "212 555-1234", "646 555-4567" ]
}
is equivalent to the following XML representation:
I guest this a general case so there must be an example for this somewhere on the internet but i haven't found it yet. So i put on forum and hope someone already knows this.
You can use an example distributed with Sausalito (28msec.com). Install the coresdk and execute:
sausalito create template -n json
then you can see and play with some json conversions in json/handlers/doublesearch.xq (online:28msec.com/source/show/json/handlers/doublesearch.xq) and json/lib/controller/search.xq (online:28msec.com/source/show/json/lib/controller/search.xq).
Is the restful webservice you are trying to integrate on the web?
Then you could use sausalito to do the transformation job as you can deploy it in the cloud. You could then access the SOAP wrapped app in the cloud like any other service on the web.
well i will do it in easier way for my hurry job...
Now, in above example, i can make a loop to get the value column.
John
null
Smith
false
21 2nd Street
....
//in here $string is the restful input message
for $c in fn:tokenize($string, ",") where fn:string-length($c) != 0
let $cut := fn:tokenize($c, ":")[last()]
let $value := fn:replace($cut,"\{|\}","")
let $seq1 := fn:insert-before($seq1,1,$value)
return <param value="{ $value }" />
====================================
So what i want to do now is : create a $seq with value is ("John", "null", "Smith" .... ) . This code is not work. Would you please take a look at my code?