• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Putting string in soap message

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to put a string inside a soap message, which am sending.
Need to put a XML(which is in string format) inside the soap message.
Please suggest me how to put that string inside the soap message.
 
Prajatna Mahunta
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me tell you one thing...we are using Java, in WAS 5.1
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is an example for reference.

 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prajatna Mahunta:
Need to put a XML(which is in string format) inside the soap message.



Let me tell you one thing...we are using Java, in WAS 5.1



I suspect that you are actually asking how to pass or return a string that contains XML with a JAX-RPC web method. Under JAX-RPC a parameter that contains plain XML has to be in a javax.xml.soap.SOAPElement - otherwise the code generator doesn't know that it has to publish it under the "xsd:any" XML Schema Type.

See also Xml document as a SOAP payload

To convert a string that contains XML to a javax.xml.soap.SOAPElement you can use something like the following:

 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prajatna Mahunta:
We generated the client class using WSAD Wizard for this WSDL file, and we found that we need to send our input xml as Parameter. Problem here is the Method is expecting complex type as parameter where as we are generating our input xml as String. here We cant cast String variable to ComplexType.



J2EE 1.4 is supposed to support "JAX-RPC Mapping Files" which describe the custom binding between WSDL and Java types. There may be a mechanism by which you can provide the Wizard with a mapping file so that you can coerce that particular XML type to a String or SOAPElement (xsd:any).

"JAX-RPC Mapping Files" are described in "7.3 JAX-RPC Mapping Deployment Descriptor" of JSR-000921 Implementing Enterprise Web Services 1.1

Ultimately it may be easier to "tweak" a local copy of the WSDL (replace the appropriate XML type with xsd:any or xsd:string in the affected message part) so that the generated Java method is more to your liking.

Another alternative is JiBX to define a mapping between your XML to the generated complex type.
[ November 20, 2008: Message edited by: Peer Reynders ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer Reynders ,

Can you tell me how to add text with xml to SOAPHeader. Since the addDocument method is not there for SOAPHeader.

Thanks
reply
    Bookmark Topic Watch Topic
  • New Topic