You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is written that this library can turn XML into JSON. I'm trying to write Node.js proxy that turn SOAP service into Rest (media JSON). And I have successful unmarshal XML response from SOAP service. The problem is that I cannot send JSON model from const unmarshall. unmarshall Object is:
How about to have method unmarshall.toJson() to extract values from this object?
This is my code:
const context = new Jsonix.Context([envelope, getFuelStationResponse]);
const unmarshaller = context.createUnmarshaller();
// Unmarshal the XML file
const unmarshall = unmarshaller.unmarshalString(xml);
//to get JSON string is not possible from unmarshall
console.log(unmarshall.value.body.any[0].childNodes[0].childNodes[1].childNodes);
Something is wrong with your mappings, you seem to get DOM object, probably your any property is mapped as DOM element and does not have a corresponding type.
The problem is that your schemas/mappings do not contain mappings for the GetFuelStationsResponse element. So Jsonix does not know how to unmarshal this element and therefore leaves DOM.
Please augment your schemas/mappings with top level element for GetFuelStationsResponse and corresponding types. You should have a global element like <xs:element name="getFuelStationsResponse" type="GetFuelStationsResponseType"/> or similar somewhere.
Yes you are right this is mapping problem. I have fix it and push changes here: https://github.com/sytolk/jsonix-support/tree/master/f/fuelprice.
Maybe it's need to have exception/warning in log for the mapping problem before Jsonix to leaves DOM?
I don`t know if this is OK but after body element from schema -> envelope.xsd its have any[0].getFuelStationsResponse.xsd This is the code that display parsed JSON now:
t.e. it's have two value for the two XSL schemas separated with any[0] or it's have some problem with body element mapping too. but this is not a big problem..
Can I skip TYPE_NAME JSON property? I think it is useless I only want to return JSON string in response (like Rest service do this) and use the same Mapping objects in Rest client app.
Activity
highsource commentedon May 9, 2017
Something is wrong with your mappings, you seem to get DOM object, probably your
anyproperty is mapped as DOM element and does not have a corresponding type.Normally, if everything's mapped you should be getting pure JSON. Please PR your test project under https://github.com/highsource/jsonix-support/f/fuelprice, I'll see about it.
sytolk commentedon May 9, 2017
Thanks @highsource https://github.com/sytolk/jsonix-support/tree/master/f/fuelprice
highsource commentedon May 9, 2017
Here's the XML you try to unmarshall:
The problem is that your schemas/mappings do not contain mappings for the
GetFuelStationsResponseelement. So Jsonix does not know how to unmarshal this element and therefore leaves DOM.Please augment your schemas/mappings with top level element for
GetFuelStationsResponseand corresponding types. You should have a global element like<xs:element name="getFuelStationsResponse" type="GetFuelStationsResponseType"/>or similar somewhere.sytolk commentedon May 10, 2017
Yes you are right this is mapping problem. I have fix it and push changes here:
https://github.com/sytolk/jsonix-support/tree/master/f/fuelprice.
Maybe it's need to have exception/warning in log for the mapping problem before Jsonix to leaves DOM?
I don`t know if this is OK but after body element from schema -> envelope.xsd its have any[0].getFuelStationsResponse.xsd This is the code that display parsed JSON now:
t.e. it's have two
valuefor the two XSL schemas separated with any[0] or it's have some problem withbodyelement mapping too. but this is not a big problem..Can I skip
TYPE_NAMEJSON property? I think it is useless I only want to return JSON string in response (like Rest service do this) and use the same Mapping objects in Rest client app.sytolk commentedon May 11, 2017
It`s fixed now thanks @highsource
vasyland commentedon Dec 1, 2017
sytolk
Could you please share an example on your fix? Thanks.
sytolk commentedon Dec 2, 2017
@vasyland I have change library to
strong-soap+wsfor SOAP (XML) to JSON converter