Announcement Announcement Module
No announcement yet.
Pass XML as String Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pass XML as String

    Hi, this is a general web service question i think.
    My web service takes a String type parameter and the string could be any valid xml document (we have another paramter with which we can get all the details as to how to interpret the xml string). The web service is implemented using AXIS.
    This works fine but one issue coming up is our clients use all kinds of SOAP client, some of them creating the SOAP payload by themselves. In that case, they have to escape the xml string parameter ( using &lt; and &gt; to escape the < and > tags). Othewise Axis on the server side will throw exceptions. If the client use axis client tool or .net, usually they do not have to do that manually.
    I'd like to see a solution that does not require the client to do any xml escaping.
    Any suggestions?

  • #2
    I just found that putting the xml in a CDATA section does the trick.


    • #3
      spring web services

      Maybe you should look at the spring-ws model instead of axis.
      With that you should be able to generate classes from your xsd (for say jaxb2), populate your class, and then marshall it all with something like:

      this.marshaller.marshal(new JAXBElement(
      new QName(NAMESPACE_URI, affiliations_RESPONSE_LOCAL_NAME), WorkflowListResponse.class, workflowResponse),result);

      The content of the fields in your class should not be a problem after that.
      I was using Axis recently and am trying the spring-ws model instead now. It's different in that you start with the contract and then code to it, whereas axis will generate a wsdl on the fly for you.
      I am liking the spring-ws model because I find it easier to debug since it is not a separate container where axis is.
      ... Rich