You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Mohan Radhakrishnan <ra...@gmail.com> on 2008/06/01 16:30:43 UTC

Document literal style - Send XML as string

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 ?

       <newnamespace:argument uri ....... >

   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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Mohan Radhakrishnan <ra...@gmail.com>.
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.

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<someprefix:test xmlns:rul="http://test.com">
<Request xsi:noNamespaceSchemaLocation="Test.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
....................
</soapenv:Envelope>

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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Mohan Radhakrishnan <ra...@gmail.com>.
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
<test:arg0>This is where the XML goes as a String</test:arg0>.

 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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Pablo Melchi <pa...@gmail.com>.
"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 &lt;

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
> 
> <?xml version=...............?>
> <soapenv:Envelope xmlns:soapenv="http:
> //schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Body><something:test
> xmlns:
> something="http://test.com">
> <something:arg0><![CDATA[<Request
> xsi:
> noNamespaceSchemaLocation="Test1.0.4.xsd"
> xmlns:xsi="http://www.w3.
> org/2001/XMLSchemainstance">
>   <Header>
> ..........
> .........
> </soapenv:Envelope>
> 
> But the service generated by somebody else seems to look for the XML as a
> child of <something:arg0>
> 
> Next question is about this 'something'. It is generated for me according to
> what rule. Can I override it ? If this WSDL is used by both the server and
> the client then there should not be any problem. That is what you are trying
> to say ?
> 
> _________________________________________________
> 
> <?xml version='1.0' encoding='UTF-8'?>
> <s0:definitions name="TestServiceDefinitions"
> targetNamespace="http://test.com" xmlns=""   
> xmlns:s0="http://schemas.xmlsoap.org/wsdl/"
>                 xmlns:s1="http://test.com"
>                 xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" >
> 
> 
> 
>   <s0:types>
>     <xs:schema attributeFormDefault="unqualified"
> elementFormDefault="qualified" targetNamespace="http://test.com"
> xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://test.com"
> xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>       <xs:element name="test">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element name="arg0" type="xs:string"/>
>           </xs:sequence>
>         </xs:complexType>
>       </xs:element>
>       <xs:element name="testResponse">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element name="return" type="xs:string"/>
>           </xs:sequence>
>         </xs:complexType>
>       </xs:element>
>     </xs:schema>
>   </s0:types>
>   <s0:message name="test">
>     <s0:part element="s1:test" name="parameters"/>
>   </s0:message>
>   <s0:message name="testResponse">
>     <s0:part element="s1:testResponse" name="parameters"/>
>   </s0:message>
>   <s0:portType name="TestPortType">
>     <s0:operation name="test" parameterOrder="parameters">
>       <s0:input message="s1:test"/>
>       <s0:output message="s1:testResponse"/>
>     </s0:operation>
>   </s0:portType>
>   <s0:binding name="TestServiceSoapBinding" type="s1:TestPortType">
>     <s2:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>     <s0:operation name="test">
>       <s2:operation soapAction="http://test.com/test" style="document"/>
>       <s0:input>
>         <s2:body parts="parameters" use="literal"/>
>       </s0:input>
>       <s0:output>
>         <s2:body parts="parameters" use="literal"/>
>       </s0:output>
>     </s0:operation>
>   </s0:binding>
>   <s0:service name="TestService">
>     <s0:port binding="s1:TestServiceSoapBinding" name="TestPort">
>       <s2:address
> location="http://localhost:8081/axis2/services/TestService"/>
>     </s0:port>
>   </s0:service>
> </s0:definitions>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Mohan Radhakrishnan <ra...@gmail.com>.
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

<?xml version=...............?>
<soapenv:Envelope xmlns:soapenv="http:
//schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body><something:test
xmlns:
something="http://test.com">
<something:arg0><![CDATA[<Request
xsi:
noNamespaceSchemaLocation="Test1.0.4.xsd"
xmlns:xsi="http://www.w3.
org/2001/XMLSchemainstance">
  <Header>
..........
.........
</soapenv:Envelope>

But the service generated by somebody else seems to look for the XML as a
child of <something:arg0>

Next question is about this 'something'. It is generated for me according to
what rule. Can I override it ? If this WSDL is used by both the server and
the client then there should not be any problem. That is what you are trying
to say ?

_________________________________________________

<?xml version='1.0' encoding='UTF-8'?>
<s0:definitions name="TestServiceDefinitions"
targetNamespace="http://test.com" xmlns=""   
xmlns:s0="http://schemas.xmlsoap.org/wsdl/"
                xmlns:s1="http://test.com"
                xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" >



  <s0:types>
    <xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" targetNamespace="http://test.com"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://test.com"
xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="test">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="arg0" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="testResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="return" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
  </s0:types>
  <s0:message name="test">
    <s0:part element="s1:test" name="parameters"/>
  </s0:message>
  <s0:message name="testResponse">
    <s0:part element="s1:testResponse" name="parameters"/>
  </s0:message>
  <s0:portType name="TestPortType">
    <s0:operation name="test" parameterOrder="parameters">
      <s0:input message="s1:test"/>
      <s0:output message="s1:testResponse"/>
    </s0:operation>
  </s0:portType>
  <s0:binding name="TestServiceSoapBinding" type="s1:TestPortType">
    <s2:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <s0:operation name="test">
      <s2:operation soapAction="http://test.com/test" style="document"/>
      <s0:input>
        <s2:body parts="parameters" use="literal"/>
      </s0:input>
      <s0:output>
        <s2:body parts="parameters" use="literal"/>
      </s0:output>
    </s0:operation>
  </s0:binding>
  <s0:service name="TestService">
    <s0:port binding="s1:TestServiceSoapBinding" name="TestPort">
      <s2:address
location="http://localhost:8081/axis2/services/TestService"/>
    </s0:port>
  </s0:service>
</s0:definitions>
-- 
View this message in context: http://www.nabble.com/Document-literal-style---Send-XML-as-string-tp17586208p17594355.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Pablo Melchi <pa...@gmail.com>.
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:

<soap:envelope>
     <soap:body>
         <myMethod>
             <myString>Some XML with scaped characters</myString>
         </myMethod>
     </soap:body>
</soap:envelope>

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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Mohan Radhakrishnan <ra...@gmail.com>.

 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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Document literal style - Send XML as string

Posted by Pablo Melchi <pa...@gmail.com>.
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 <radhakrishnan.mohan@gmail.com 
 > 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 ?
>
>       <newnamespace:argument uri ....... >
>
>   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: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org