Add cookie to HTTP request header when calling web service
bruno2May 23 2010 — edited Dec 7 2010I'm trying to call web service using JDeveloper 11g. I successfully generated web service proxy from WSDL document. I can successfully call this particular web service's method "login" which returns "session_id", which then needs to be inserted as a cookie in the HTTP request header in later calls to other methods. This is how the HTTP request header should look like:
POST /webservice HTTP/1.1
Host: registrar.carnet.hr
Connection: Keep-Alive
User-Agent: .hr domene
Content-Type: text/xml; charset=utf-8
SOAPAction: "https://registrar.carnet.hr/webservice#get_domain_name"
Content-Length: 532
Cookie: session_id=f3po0ba01a47gd64792151ee43a25765;
How can this be accomplished? There is not much code that I wrote, everything is generated by JDeveloper's wizard...
public static void main(String[] args) {
try {
RegistrarServicePortPortClient client =
new RegistrarServicePortPortClient();
client.setPortCredentialProviderList();
// add your code here
String login;
login = client.login("username", "password");
System.out.println(login);
String myCookie = "session_id="+login;
System.out.println(myCookie);
*// what can be done to add myCookie to the HTTP request header?*
} catch (Exception ex) {
ex.printStackTrace();
}
}
Thanks in advance,
Bruno