This discussion is archived
3 Replies Latest reply: May 25, 2012 4:21 AM by user696 RSS

Topdown JAVA WS and xsd:anyType

robert224810 Explorer
Currently Being Moderated
Hi,

I am developing a JAVA webservice using the Top-down method.

I have created the code using the JDeveloper File -> New -> Java Web Service From WSDL

Part of the reply payload is a general xml message and I have used xsd:anyType in the WSDL

I have created this code:
ResponseMessageType resp = new ResponseMessageType();

ResponseMessageType.Messages msgs = new ResponseMessageType.Messages();
resp.setMessages(msgs);

msgs.getMessage().add("<a xmlns=\"eee\"><b></b><c><d>FF</d></c></a>");
msgs.getMessage().add("<a xmlns=\"eee\"><b></b><c><d>FF22</d></c></a>");
msgs.getMessage().add("<a xmlns=\"eee\"><b></b><c><d>F333F</d></c></a>");

return resp;

This returns a result of:
<?xml version = '1.0' encoding = 'UTF-8'?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<responseMessage xmlns="http://www.ic.ac.uk/dev/RJMTest_JMSSyncQuery_WS">
<messages>
<message xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">&amp;lt;a xmlns="eee">&amp;lt;b>&amp;lt;/b>&amp;lt;c>&amp;lt;d>FF&amp;lt;/d>&amp;lt;/c>&amp;lt;/a></message>
<message xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">&amp;lt;a xmlns="eee">&amp;lt;b>&amp;lt;/b>&amp;lt;c>&amp;lt;d>FF22&amp;lt;/d>&amp;lt;/c>&amp;lt;/a></message>
<message xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">&amp;lt;a xmlns="eee">&amp;lt;b>&amp;lt;/b>&amp;lt;c>&amp;lt;d>F333F&amp;lt;/d>&amp;lt;/c>&amp;lt;/a></message>
</messages>
</responseMessage>
</S:Body>
</S:Envelope>

As you can see this is not quite what I want. It has replaced the < with &lt;
I need it to return the contents of the string as if it was xml.
Does anyone know what I am doing wrong?

Thanks
Robert

The full source is below: (Everything else in the project is the autogenerated JDeveloper stuff)

package uk.ac.ic.devtest.rjmtest_jmssyncquery_ws.ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;

import uk.ac.ic.devtest.rjmtest_jmssyncquery_ws.types.ObjectFactory;
import uk.ac.ic.devtest.rjmtest_jmssyncquery_ws.types.RequestMessageType;
import uk.ac.ic.devtest.rjmtest_jmssyncquery_ws.types.ResponseMessageType;

@WebService(name = "execute_ptt", targetNamespace = "http://xmlns.oracle.com/TIPP_SOA_Tests2/RJMTest_Role3EBS/RJMTest_JMSSyncQuery_WS", serviceName = "mainService", portName = "execute_pttSOAP12BindingPort_pt", wsdlLocation = "/WEB-INF/wsdl/mainService.wsdl")
@XmlSeeAlso( { ObjectFactory.class })
@javax.jws.soap.SOAPBinding(style = javax.jws.soap.SOAPBinding.Style.DOCUMENT, parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.BARE)
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class Execute_pttImpl {
public Execute_pttImpl() {
}

@javax.jws.soap.SOAPBinding(parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.BARE)
@Action(input = "http://xmlns.oracle.com/TIPP_SOA_Tests2/RJMTest_Role3EBS/RJMTest_JMSSyncQuery_WS/QueryQueue", output = "http://xmlns.oracle.com/TIPP_SOA_Tests2/RJMTest_Role3EBS/RJMTest_JMSSyncQuery_WS/execute_ptt/QueryQueueResponse")
@WebMethod(operationName = "QueryQueue", action = "http://xmlns.oracle.com/TIPP_SOA_Tests2/RJMTest_Role3EBS/RJMTest_JMSSyncQuery_WS/QueryQueue")
@WebResult(name = "responseMessage", targetNamespace = "http://www.ic.ac.uk/dev/RJMTest_JMSSyncQuery_WS", partName = "part1")
public ResponseMessageType queryQueue(@WebParam(name = "requestMessage", partName = "part1", targetNamespace = "http://www.ic.ac.uk/dev/RJMTest_JMSSyncQuery_WS")
RequestMessageType part1) {
ResponseMessageType resp = new ResponseMessageType();

ResponseMessageType.Messages msgs = new ResponseMessageType.Messages();
resp.setMessages(msgs);

msgs.getMessage().add("<a xmlns=\"eee\"><b></b><c><d>FF</d></c></a>");
msgs.getMessage().add("<a xmlns=\"eee\"><b></b><c><d>FF22</d></c></a>");
msgs.getMessage().add("<a xmlns=\"eee\"><b></b><c><d>F333F</d></c></a>");

return resp;
}
}
  • 1. Re: Topdown JAVA WS and xsd:anyType
    user696 Explorer
    Currently Being Moderated
    This works as designed as per the HTML standard:

    Four character entity references deserve special mention since they are frequently used to escape special characters:

    * "&lt;" represents the < sign.
    * "&gt;" represents the > sign.
    * "&amp;" represents the & sign.
    * "&quot; represents the " mark.

    Authors wishing to put the "<" character in text should use "&lt;" (ASCII decimal 60) to avoid possible confusion with the beginning of a tag (start tag open delimiter). Similarly, authors should use "&gt;" (ASCII decimal 62) in text instead of ">" to avoid problems with older user agents that incorrectly perceive this as the end of a tag (tag close delimiter) when it appears in quoted attribute values.

    Use(Escaped) by <![CDATA[ ]]> or XML entities: &lt; &gt; it should work

    Please refer to the link in the references section regarding these specific characters.
    http://www.w3.org/TR/html4/charset.html
    http://stackoverflow.com/questions/7849666/java-web-service-returns-string-with-gt-and-lt-instead-of-and

    Regards,
    Sunil
  • 2. Re: Topdown JAVA WS and xsd:anyType
    robert224810 Explorer
    Currently Being Moderated
    Hi,

    I am using the top down approach, defining the WSDL first.

    The reason I need to use xsd:anyType is because my service needs to dequeue an xml message from the JMS queue. I will not know the schema and will not be able to code it into the service.

    I need to make it work so that when I write:
    msgs.getMessage().add("<a xmlns=\"eee\"><c><d>FF</d></c>");

    the java stuff should leave the string alone, not convert < to &lt; or any other charactor and pass it out as part of the valid xml output.

    Robert
  • 3. Re: Topdown JAVA WS and xsd:anyType
    user696 Explorer
    Currently Being Moderated
    Hi Robert,

    Can you check below link it tells how to process XSD:anytype inside the Endpoint Implementation

    http://java.sun.com/developer/technicalArticles/xml/jaxrpcpatterns3/ (check for Using the xsd:anyType in WSDL)
    http://java.sun.com/developer/technicalArticles/xml/jaxrpcpatterns/index4.html#9

    Regards,
    Sunil

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points