You can use the CXF stuff all over again if you are willing to write an XML schema for your XML and write a bit of Java.
In the CXF code, it wouldn't be too hard to run SchemaJavascriptBuilder to create the necessary functions to serialize and deserialize. then you just parse the string appropriate Javascript DOM function. On Wed, Dec 2, 2009 at 8:33 PM, noosy <[email protected]> wrote: > > Thanks again! > > Another question if you don't mind.. > > I'm looking for the equivalent of how I would normally use xmlbeans in Java > - that I can do in JS. > > More specifically, my web service returns xml within xml if that makes > sense. My generated wsdl2js CXF code allows me to work nicely with the > 'outer' xml described by my web service but the xml response that I get back > contains a metadata tag that contains more xml adhering to a schema that is > not known to the web service. Currently I'm not sure what the best way is to > work with the 'inner' xml in JS. > > If I was doing this in Java I would bind the 'inner' xml to a Java type > using XML Beans but alas I am in the strange new world of JS and I am not > sure what my best options are (I can only think of ugly ways). I want to use > the 'inner' xml in both directions. Eg. Read the 'inner' xml from out of my > WS xml response and turn it into a workable js type and take a js type and > turn it into xml to pass back to my WS. I have the schema for the 'inner' > xml so is there a tool that will do this for me in js? > > > > bimargulies wrote: >> >> I just submitted a fix to CXF-2568 which is your problem with the enum >> default values. >> >> On Wed, Nov 18, 2009 at 6:53 PM, noosy >> <[email protected]> wrote: >>> >>> The latest snapshot has fixed the problem with the header - thanks very >>> much >>> :) >>> >>> One question regarding the generated code for the following element >>> (declared in a schema referenced by my wsdl): >>> >>> - <xsd:element default="COLD" name="temperature"> >>> - <xsd:annotation> >>> <xsd:documentation xml:lang="en">Temp.</xsd:documentation> >>> </xsd:annotation> >>> - <xsd:simpleType> >>> - <xsd:restriction base="xsd:string"> >>> - <xsd:enumeration value="WARM"> >>> - <xsd:annotation> >>> <xsd:documentation >>> xml:lang="en">Warm temp.</xsd:documentation> >>> </xsd:annotation> >>> </xsd:enumeration> >>> - <xsd:enumeration value="HOT"> >>> - <xsd:annotation> >>> <xsd:documentation xml:lang="en">Hot >>> temp.</xsd:documentation> >>> </xsd:annotation> >>> </xsd:enumeration> >>> - <xsd:enumeration value="COLD"> >>> - <xsd:annotation> >>> <xsd:documentation xml:lang="en">Cold >>> temp.</xsd:documentation> >>> </xsd:annotation> >>> </xsd:enumeration> >>> </xsd:restriction> >>> </xsd:simpleType> >>> </xsd:element> >>> >>> A method is generated and the default value for temp is set: >>> >>> function myNamespace_temperature(){ >>> ... >>> this._temperature = COLD; >>> } >>> >>> To get my code to work, I need to turn COLD into a String. E.g. 'COLD'. >>> Is >>> this a new problem with the auto generated code? >>> >>> Currently, I have manually modified the generated js file to get around >>> this >>> and it is working as expected. >>> >>> Your advice would again be appreciated - if you require more info please >>> just ask. >>> >>> Thanks >>> >>> >>> >>> noosy wrote: >>>> >>>> Sorry Benson, I only just got a chance to look at this today. Thanks so >>>> much - will try the snapshot tomorrow and post back my results. >>>> >>>> >>>> bimargulies wrote: >>>>> >>>>> https://issues.apache.org/jira/browse/CXF-2513. Fixed. Try another >>>>> snapshot. >>>>> >>>>> On Wed, Oct 21, 2009 at 7:51 AM, Benson Margulies >>>>> <[email protected]>wrote: >>>>> >>>>>> I will try to make sense of this tonight. However, I am likelier to be >>>>>> much >>>>>> more helpful much faster if you can either construct a test case you >>>>>> can >>>>>> share or at least share the XML Schema fragments relevant to this >>>>>> problem. >>>>>> This kind of problem boils down to having generated Javascript that is >>>>>> not >>>>>> on the same page as the XML Schema (assuming that your service >>>>>> corresponds >>>>>> to its schema correctly). >>>>>> >>>>>> >>>>>> On Wed, Oct 21, 2009 at 3:49 AM, noosy >>>>>> <[email protected] >>>>>> > wrote: >>>>>> >>>>>>> >>>>>>> Awesome, I got the latest snapshot and the missing code has been >>>>>>> generated >>>>>>> :) >>>>>>> >>>>>>> However... I tried to call a simple WS operation, I can see that I am >>>>>>> getting the SOAP envelope back containing the result but my generated >>>>>>> js >>>>>>> function ns_getResult_op_onsuccess(client, responseXml) >>>>>>> is letting me down. I will try and describe the problem as best I >>>>>>> can. >>>>>>> >>>>>>> In FireBug, the POST Response looks like this: >>>>>>> >>>>>>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> >>>>>>> <env:Header/> >>>>>>> <env:Body> >>>>>>> <java:getResultResponse xmlns:java="java:blah"> >>>>>>> <java:result>myResult</java:result> >>>>>>> </java:getResultResponse> >>>>>>> </env:Body> >>>>>>> </env:Envelope> >>>>>>> >>>>>>> Within the method below, I will show you what I see in Firebug as >>>>>>> comments >>>>>>> for each line.. >>>>>>> >>>>>>> ns_getResult_op_onsuccess(client, responseXml) >>>>>>> { >>>>>>> if(client.user_onsuccess) >>>>>>> { >>>>>>> var responseObject = null; >>>>>>> var element = responseXml.documentElement; // element = >>>>>>> envelope >>>>>>> this.jsutils.trace('responseXml: ' + >>>>>>> this.jsutils.traceElementName(element)); >>>>>>> element = this.jsutils.getFirstElementChild(element); // >>>>>>> element >>>>>>> = >>>>>>> header >>>>>>> this.jsutils.trace('first element child: ' + >>>>>>> this.jsutils.traceElementName(element)); >>>>>>> element = this.jsutils.getFirstElementChild(element); // >>>>>>> element = >>>>>>> null >>>>>>> this.jsutils.trace('part element: ' + >>>>>>> this.jsutils.traceElementName(element)); // element = null >>>>>>> this.jsutils.trace('calling >>>>>>> blah_getResultResponse_deserializeResponse'); >>>>>>> responseObject = >>>>>>> blah_getResultResponse_deserializeResponse(this.jsutils, element); >>>>>>> client.user_onsuccess(responseObject); >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> So the problem is arising where element = null. >>>>>>> >>>>>>> When I look at the documentElement in FireBug it looks like this: >>>>>>> >>>>>>> documentElement: envelope >>>>>>> childElementCount: 2 >>>>>>> children: header, body >>>>>>> 0: header >>>>>>> childElementCount: 0 >>>>>>> 1: body >>>>>>> childElementCount: 1 >>>>>>> children: getresultresponse >>>>>>> 0: getresultresponse >>>>>>> childElementCount: 1 >>>>>>> children: result >>>>>>> 0: result >>>>>>> textContent: myResult >>>>>>> >>>>>>> Is the problem my XML (I'm using a third party WSDL so I can't change >>>>>>> it) >>>>>>> or >>>>>>> is this a problem with the generated wsdl2js code that parses the >>>>>>> responseXML? >>>>>>> >>>>>>> BTW I greatly appreciate your help so far! >>>>>>> >>>>>>> >>>>>>> >>>>>>> bimargulies wrote: >>>>>>> > >>>>>>> > I've made a fix to the top-level problem to trunk. Try the next >>>>>>> snapshot. >>>>>>> > >>>>>>> >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://www.nabble.com/WSD2JS-Not-Creating-Schema-Objects-tp25913919p25987975.html >>>>>>> Sent from the cxf-user mailing list archive at Nabble.com. >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/WSD2JS-Not-Creating-Schema-Objects-tp25913919p26418028.html >>> Sent from the cxf-user mailing list archive at Nabble.com. >>> >>> >> >> > > -- > View this message in context: > http://old.nabble.com/WSD2JS-Not-Creating-Schema-Objects-tp25913919p26619651.html > Sent from the cxf-user mailing list archive at Nabble.com. > >
