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 brijesh <br...@gmail.com> on 2009/06/12 09:25:50 UTC

Axis client converts < > character to < > in payload

hello there, 

i have following wsdl file 

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:tns="http://www.ekaplus.com/NotifyEvent/"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="NotifyEvent"
	targetNamespace="http://www.ekaplus.com/NotifyEvent/">
	<wsdl:types>
		<xsd:schema
			targetNamespace="http://www.ekaplus.com/NotifyEvent/">
			<xsd:element name="notifyEvent">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="in" type="xsd:string" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="notifyEventResponse">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="out" type="xsd:string" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
		</xsd:schema>
	</wsdl:types>
	<wsdl:message name="notifyEventRequest">
		<wsdl:part element="tns:notifyEvent" name="param_in" />
	</wsdl:message>
	<wsdl:message name="notifyEventResponse">
		<wsdl:part element="tns:notifyEventResponse" name="param_out" />
	</wsdl:message>
	<wsdl:portType name="NotifyEventPortType">
		<wsdl:operation name="notifyEvent">
			<wsdl:input message="tns:notifyEventRequest" />
			<wsdl:output message="tns:notifyEventResponse" />
		</wsdl:operation>
	</wsdl:portType>
	<wsdl:binding name="NotifyEventBinding"
		type="tns:NotifyEventPortType">
		<soap:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" />
		<wsdl:operation name="notifyEvent">
			<soap:operation
				soapAction="http://www.ekaplus.com/NotifyEvent/notifyEvent" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:service name="NotifyEventService">
		<wsdl:port binding="tns:NotifyEventBinding"
			name="NotifyEventPort">
			<soap:address
				location="http://localhost:8092/NotifyEventService" />
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>


when I call the service from axis client it converts xml  < > character to 
http://www.nabble.com/file/p23994109/sp_caracter.jpg   in payload , i am
setting xml string (<test> test msg</test>) as input message but in server I
get payload as  http://www.nabble.com/file/p23994109/sp_caracter.jpg  which
causes exception, is there anyway  option in axis client to not to convert
these character and send the message as it is to service?

When I tested the same service with SOAP UI it works and send the message as
it is, the issue is with axis client code. 

following is client code snippet

 public void test1NotifyEventPortNotifyEvent() throws Exception {
        com.ekaplus.www.NotifyEvent.NotifyEventBindingStub binding;
        
       
       
        try {
            binding = (com.ekaplus.www.NotifyEvent.NotifyEventBindingStub)
                          new
com.ekaplus.www.NotifyEvent.NotifyEventServiceLocator().getNotifyEventPort();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            if(jre.getLinkedCause()!=null)
                jre.getLinkedCause().printStackTrace();
            throw new junit.framework.AssertionFailedError("JAX-RPC
ServiceException caught: " + jre);
        }
        assertNotNull("binding is null", binding);

        // Time out after a minute
        binding.setTimeout(60000);

        // Test operation
        java.lang.String value = null;
        value = binding.notifyEvent(new java.lang.String("<test>test message
</test>"));
        // TBD - validate results
        System.out.println("ResponseDoc::"+value);
    }

 
thanks & regards

Brijesh N K


-- 
View this message in context: http://www.nabble.com/Axis-client-converts-%3C-%3E-character-to---lt---gt--in-payload-tp23994109p23994109.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis client converts < > character to < > in payload

Posted by Paul Fremantle <pz...@gmail.com>.
The problem is that your parameter is a string, so in order to
transmit the XML, it is encoding it as a string. If you want to really
transmit XML, change the type to xsd:any.

Paul

On Fri, Jun 12, 2009 at 8:25 AM, brijesh<br...@gmail.com> wrote:
>
> hello there,
>
> i have following wsdl file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>        xmlns:tns="http://www.ekaplus.com/NotifyEvent/"
>        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>        xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="NotifyEvent"
>        targetNamespace="http://www.ekaplus.com/NotifyEvent/">
>        <wsdl:types>
>                <xsd:schema
>                        targetNamespace="http://www.ekaplus.com/NotifyEvent/">
>                        <xsd:element name="notifyEvent">
>                                <xsd:complexType>
>                                        <xsd:sequence>
>                                                <xsd:element name="in" type="xsd:string" />
>                                        </xsd:sequence>
>                                </xsd:complexType>
>                        </xsd:element>
>                        <xsd:element name="notifyEventResponse">
>                                <xsd:complexType>
>                                        <xsd:sequence>
>                                                <xsd:element name="out" type="xsd:string" />
>                                        </xsd:sequence>
>                                </xsd:complexType>
>                        </xsd:element>
>                </xsd:schema>
>        </wsdl:types>
>        <wsdl:message name="notifyEventRequest">
>                <wsdl:part element="tns:notifyEvent" name="param_in" />
>        </wsdl:message>
>        <wsdl:message name="notifyEventResponse">
>                <wsdl:part element="tns:notifyEventResponse" name="param_out" />
>        </wsdl:message>
>        <wsdl:portType name="NotifyEventPortType">
>                <wsdl:operation name="notifyEvent">
>                        <wsdl:input message="tns:notifyEventRequest" />
>                        <wsdl:output message="tns:notifyEventResponse" />
>                </wsdl:operation>
>        </wsdl:portType>
>        <wsdl:binding name="NotifyEventBinding"
>                type="tns:NotifyEventPortType">
>                <soap:binding style="document"
>                        transport="http://schemas.xmlsoap.org/soap/http" />
>                <wsdl:operation name="notifyEvent">
>                        <soap:operation
>                                soapAction="http://www.ekaplus.com/NotifyEvent/notifyEvent" />
>                        <wsdl:input>
>                                <soap:body use="literal" />
>                        </wsdl:input>
>                        <wsdl:output>
>                                <soap:body use="literal" />
>                        </wsdl:output>
>                </wsdl:operation>
>        </wsdl:binding>
>        <wsdl:service name="NotifyEventService">
>                <wsdl:port binding="tns:NotifyEventBinding"
>                        name="NotifyEventPort">
>                        <soap:address
>                                location="http://localhost:8092/NotifyEventService" />
>                </wsdl:port>
>        </wsdl:service>
> </wsdl:definitions>
>
>
> when I call the service from axis client it converts xml  < > character to
> http://www.nabble.com/file/p23994109/sp_caracter.jpg   in payload , i am
> setting xml string (<test> test msg</test>) as input message but in server I
> get payload as  http://www.nabble.com/file/p23994109/sp_caracter.jpg  which
> causes exception, is there anyway  option in axis client to not to convert
> these character and send the message as it is to service?
>
> When I tested the same service with SOAP UI it works and send the message as
> it is, the issue is with axis client code.
>
> following is client code snippet
>
>  public void test1NotifyEventPortNotifyEvent() throws Exception {
>        com.ekaplus.www.NotifyEvent.NotifyEventBindingStub binding;
>
>
>
>        try {
>            binding = (com.ekaplus.www.NotifyEvent.NotifyEventBindingStub)
>                          new
> com.ekaplus.www.NotifyEvent.NotifyEventServiceLocator().getNotifyEventPort();
>        }
>        catch (javax.xml.rpc.ServiceException jre) {
>            if(jre.getLinkedCause()!=null)
>                jre.getLinkedCause().printStackTrace();
>            throw new junit.framework.AssertionFailedError("JAX-RPC
> ServiceException caught: " + jre);
>        }
>        assertNotNull("binding is null", binding);
>
>        // Time out after a minute
>        binding.setTimeout(60000);
>
>        // Test operation
>        java.lang.String value = null;
>        value = binding.notifyEvent(new java.lang.String("<test>test message
> </test>"));
>        // TBD - validate results
>        System.out.println("ResponseDoc::"+value);
>    }
>
>
> thanks & regards
>
> Brijesh N K
>
>
> --
> View this message in context: http://www.nabble.com/Axis-client-converts-%3C-%3E-character-to---lt---gt--in-payload-tp23994109p23994109.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>



-- 
Paul Fremantle
Co-Founder and CTO, WSO2
Apache Synapse PMC Chair
OASIS WS-RX TC Co-chair

blog: http://pzf.fremantle.org
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com