RE: Document literal style - Send XML as string
Hi Mohan, (I'm copying the axis-user since I noticed you also posted this question there, too.) The problem seems to be with your code. Keep these in mind: 1) arg0 is a string type. 2) Since you are placing an XML-formatted string in arg0, the string must be XML-escaped. Don't put raw XML in arg0. 3) The xmlObject.set(obj) method is meant only to take in the same type of object (or a subclass of that object) that you are calling the set() on. It just copies over the value of the input object. So you can do objectA.set(otherObjectA), but should not do objectA.set(objectB). 4) Don't do: test.setArg0(request.toString()); // This is probably why you're getting CDATA. And don't do: test.set(request); // request and test are not the same types Instead, you need to do: String escapedVal = ... // Convert request to an XML string, and then XML-escape it. test.setArg0(escapedVal); On the server side, your code will need to first take arg0 and "unescape" the value before it can work with it as proper XML. It should not assume to get raw XML in arg0. -Vinh -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 03, 2008 3:09 AM To: [EMAIL PROTECTED] Subject: Document literal style - Send XML as string Hi, There is lot of code in this mail. Hope I am asking the right question. I am using the doc/lit style to send a xs:string type. Now if I post an entire XML then it gets wrapped in CDATA. I am using Axis 2 XMLBeans bindings. The WSDL is pasted at the end. The SOAP message is http://test.com";>
Re: Document literal style - Send XML as string
Hi, In the code shown in my earlier reply I replaced setArg0( request.toString() ); with set( getXmlObject() ); //XMLBeans API I use XMLBeans Axis 2 bindings. instead of CDATA wrapped XML I get by XML as a child like this. http://schemas.xmlsoap.org/soap/envelope/";> http://test.com";> http://www.w3.org/2001/XMLSchemainstance";> Which of these two styles is valid according to the WSDL ? Are both acceptable ? I still do not know where "someprefix" is coming from. Thanks, Mohan -- View this message in context: http://www.nabble.com/Document-literal-style---Send-XML-as-string-tp17586208p17618402.html Sent from the Axis - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Document literal style - Send XML as string
Hi, This is the code I am using. WSDL2Java is used. I meant to say that SOAP UI gave me a SOAP message similar to what I get using this method. It is like this This is where the XML goes as a String. My operation name in the WSDL does not match the the prefix 'test'. java2wsdl has -tp( targetnamespaceprefix override ). So I thought I can override it using wsdl2java also. stub = new TestServiceStub( SECURE_WEB_SERVICE ); document = TestDocument.Factory.newInstance(); File file = new File("Request.xml" ); Request request = Request. Factory. parse( getXml( file ) ); //Set XML as string test = document.addNewTest(); test.setArg0( request.toString() ); document.setTest( test ); Basically my question is - Does the SOAP message match my WSDL contract ? Thanks, Mohan -- View this message in context: http://www.nabble.com/Document-literal-style---Send-XML-as-string-tp17586208p17616168.html Sent from the Axis - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Document literal style - Send XML as string
"Something" is generated according to the operation name defined in your WSDL. With this I'm assuming that you are using the WSDL2Java tool or eclipse plug in. I still don't understand completely your problem. Is the SOAPUI able to send a successful message to the WS? What are you receiving back? I'll do a test later but what is curious to me is the fact that in your SOAP message the XML string parameter is not been escaped as < What code are you using to call your stub? -Pablo Melchi http://pablo-melchi.blogspot.com http://www.linkedin.com/pub/8/747/354 Mohan Radhakrishnan wrote: Hi, The WSDL is copied at the end of this mail. According to soap UI and the stub bindings what I am sending seems to be right. What I am sending is http://test.com";>
Re: Document literal style - Send XML as string
Hi, The WSDL is copied at the end of this mail. According to soap UI and the stub bindings what I am sending seems to be right. What I am sending is http://test.com";>
Re: Document literal style - Send XML as string
If I'm assuming the right thing. Your requirement is about sending a XML as an String through a Web Service. So what you are doing is something like this: Some XML with scaped characters The CDATA tag is helping to scape your XML so the parsers don't mix it with your SOAP evelope. The namespace should be already working fine since your stub was created based on the WSDL but if you still want to change it you can take a look to this: http://wso2.org/library/2060 Now my question would be... are you receiving any error? -Pablo Melchi pablo-melchi.blogspot.com Mohan Radhakrishnan wrote: What is the difference ? My WSDL requires me to pass a string parameter. I generated XMLBeans bindings and Axis2 stubs. There is a setter method generated and I set the XML that I want to pass. What is the rule in this case ? Should I set it as a child or let it pass the CDATA ? My second questions is about the targetnamespaceprefix that is automatically generated ? I think it is. Can I set my own prefix ? Thanks, Mohan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Document literal style - Send XML as string
What is the difference ? My WSDL requires me to pass a string parameter. I generated XMLBeans bindings and Axis2 stubs. There is a setter method generated and I set the XML that I want to pass. What is the rule in this case ? Should I set it as a child or let it pass the CDATA ? My second questions is about the targetnamespaceprefix that is automatically generated ? I think it is. Can I set my own prefix ? Thanks, Mohan -- View this message in context: http://www.nabble.com/Document-literal-style---Send-XML-as-string-tp17586208p17586880.html Sent from the Axis - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Document literal style - Send XML as string
I think that the problem is that your are sending a string inside a soap message and the soap message is created in the doc/lit style. Probably you want to use a binding framework to create that xml or check how to include it as a child of your payload -Pablo Melchi pablo-melchi.blogspot.com On Jun 1, 2008, at 9:30 AM, Mohan Radhakrishnan <[EMAIL PROTECTED] > wrote: Hi, I am using the doc/lit style to send a xs:string type. Now if I post an entire XML then it gets wrapped in CDATA. I am using Axis 2 XMLBeans bindings. I have these questions. 1. Does this style of sending XML as string require CDATA ? 2. A new namespace is added like this in the SOAP message when invoking the operation ? I am not specifying this 'newnamespace' anywhere. What is the rule for generating this 'newnamespace' ? I will post the WSDL and actual SOAP message if this info. is not sufficient. Thanks, Mohan -- View this message in context: http://www.nabble.com/Document-literal-style---Send-XML-as-string-tp17586208p17586208.html Sent from the Axis - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]