473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Add a header to a SOAP HTTP request

OK I have java code which creates the following XML SOAP message:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  3. <soap-env:Header/>
  4. <soap-env:Body>
  5. <GetAppList xmlns="https://***.***.***.***/***/***.asmx">
  6. <requestId>1</requestId>
  7. <laNumber>5</laNumber>
  8. <hashCode>123456</hashCode>
  9. </GetAppList>
  10. </soap-env:Body></soap-env:Envelope>
I need the message to have a header before the xml code so it would look like:

Expand|Select|Wrap|Line Numbers
  1. Host: ***.***.***.***
  2. Content-Type: text/xml; charset=utf-8
  3. Content-Length: length
  4. SOAPAction: "http://***.***.***.***/***/***"
  5.  
  6. <?xml version="1.0" encoding="UTF-8"?>
  7. <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header/><soap-env:Body><GetAppList xmlns="https://***.***.***.***/***/***.asmx">
  8. <requestId>1</requestId>
  9. <laNumber>5</laNumber>
  10. <hashCode>123456</hashCode>
  11. </GetAppList>
  12. </soap-env:Body></soap-env:Envelope>
The java code I have used to create this message is as follows:

Expand|Select|Wrap|Line Numbers
  1. MessageFactory factory  = MessageFactory.newInstance();
  2.             SOAPMessage message     = factory.createMessage();
  3.             SOAPPart soapPart       = message.getSOAPPart();
  4.             SOAPEnvelope envelope   = soapPart.getEnvelope();
  5.  
  6.             SOAPBody body           = envelope.getBody();
  7.  
  8.             SOAPFactory soapFactory             = SOAPFactory.newInstance();
  9.             Name bodyName                          = soapFactory.createName("GetAppList","","https://***.***.***.***/***/***.asmx");
  10.             SOAPBodyElement bodyElement           = body.addBodyElement(bodyName);
  11.  
  12.  
  13.             //Create nodes for sending requestId, laNumber and hashCode
  14.             Name nameRequestId = soapFactory.createName("requestId");
  15.             SOAPElement requestId = bodyElement.addChildElement(nameRequestId);
  16.             requestId.addTextNode("1");
  17.  
  18.             Name nameLaNumber = soapFactory.createName("laNumber");
  19.             SOAPElement laNumber = bodyElement.addChildElement(nameLaNumber);
  20.             laNumber.addTextNode(lpaCode);
  21.  
  22.             Name nameHashCode = soapFactory.createName("hashCode");
  23.             SOAPElement hashCode = bodyElement.addChildElement(nameHashCode);
  24.             hashCode.addTextNode(encryptedHashCode);
Could someone please help me out!
Sep 23 '08 #1
1 5091
Dököll
2,364 Expert 2GB
Looks like you're pretty savvy at this stuff, if you can create such a message. Any errors at all, or you just don't know how to get a header...

Sorry for your troubles!
Nov 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ramas | last post by:
Hi, I am new to PHP scripting and i am trying to connect to a soap server (as mentioned below) using the SOAP extension comesup with PHP. Now my requirement is to add my HTTP header fields along...
0
by: Michael Jackson | last post by:
I have attempted to mark up a service and it's methods so that it doesn't require the SOAPAction HTTP header to resolve the methods being called, this is done from first element in <SOAP-ENV:Body>...
6
by: john deviney | last post by:
I have a C#/.Net 1.1 client talking to a Java based web service. I need to insert a soap header on the client side which is expected on the server side. Currently, the Java ws provider, Axis, does...
0
by: IT Drone | last post by:
I suspect what I want to do is simple, but after hours of googling I can't come up with an answer. I'm consuming a Java-based web service from an ASP.NET app. I want a request that includes 3...
5
by: vthakur | last post by:
Hello: I have a Axis Web Service that sets the sessionid in the SOAP header for persisting the session. The client is a .Net client that processes the header as an Unknown Header. It sets the...
2
by: Kevin Eldridge | last post by:
Hi, I'm trying to call a java web service and i need some help in creating a custom SOAP header in c#. I need to access to a Web service that implements authorization policy, by using a session...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
6
by: John | last post by:
I'm trying to call a Webservice (Non-.NET) That requires the insertion of security credentials into the SOAP header. Up until know I've been creating Dynamic proxy classes to call web services and...
0
by: broersen | last post by:
Hello, Does someone know how to create manually the header for an SOAP message, without having an WSDL? I also use an X509 certificate for connecting to the webservice. Can anyone help me to get...
0
by: broersen | last post by:
Hello, Does someone know how to create manually the header for an SOAP message, without having an WSDL? I also use an X509 certificate for connecting to the webservice. Can anyone help me to get...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.