• 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

adding arbitary xml to soap headers using SAAJ

 
Greenhorn
Posts: 28
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using SAAJ to access web service. I am having a arbitary xml in my soap request. I am forming that xml seperately. but the problem is I am unable to add that xml document to the header element(In Soap body I can add another xml through body.addDocument() but Soap Header doesn't have one).I tried using header.addTextNode() but the markups are not coming properly. Please help me.

Thanks & Regards,
Vignesh
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems to me that adding arbitrary XML to SOAP Headersis contrary to the whole SOAP design, where headers are supposed to be processing information and the body is the arbitrary XML message to be delivered.

Why not just attach it as a SAAJ attachment?

Bill
 
vignesh bala
Greenhorn
Posts: 28
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I think should have describe my problem more clearly. I am using xml beans to construct the soap message. my soap message has a message header in the header field. The message header itself is a xml defined by the schema. I am converting these schemas in to java bean format using xml beans. The process I am following is:
1. form message header(xml).
2. form bodyXml (which is again defined by a seperate schema)
3. using saaj form soap request
4. get the soap header
5. add message header(xml) to the header
6. get soap body
7. add bodyXml to soap body
8. send soap message

In the above steps I can't able to perform the 5th step.Please suggest me if there is any way to achive this.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Bill said, it's not a good idea to stuff XML into a SOAP header. But if for some reason (which one?) you have to do it, it should be possible. What does the XML look like that you are trying to put there, and what exactly is happening if you do?
 
vignesh bala
Greenhorn
Posts: 28
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must write a web service client to access a web service which requires the requests in certain format(The request schema requires an xml in header).I give the sample request below:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header >
<MessageHeader MessageID="0000" MessageName="ABCD" TimeStamp="mmddyyHHMMSS"/>
</soap:Header>
<soap:Body >
<..body xml..>
</soap:Body>
</soap:Envelope>


As I already told, I used xml beans to create the message header. when I used header.appendChild(node);, I am getting the below error:



Then I tried converting xml asstring and add it to header using header.setTextNode(String). It ran withoutany exception but the markups are coming like < > etc. so due to this the web service gives fault response. I am new to soap and I am seriously doubting whether my approach is right and also is there any other way to acheive the above message format?.Thaks for all the help
 
vignesh bala
Greenhorn
Posts: 28
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey sorry guys, In my previous post, I meant to say markups are coming as

<

and

>

. But they came as < and > because I used markup charecters .
 
vignesh bala
Greenhorn
Posts: 28
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry its lt & rt.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this was my problem I would be using TCPMON to capture the exact text being sent.

Why are you generating the String by going through XML, just build it as a string directly and gain control. The XML serialization may be doing stuff to your input.

Bill
 
vignesh bala
Greenhorn
Posts: 28
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill,
I'll try your advice
 
I like tacos! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic