Simon,
I was able to figure out how to pass a cookie in a WSIF/SOAP over HTTP
request. I had to directly access the Axis Call:
WSIFPort_ApacheAxis port = (WSIFPort_ApacheAxis) service.getPort();
Call call = port.getCall();
String cookies =
(String) call.getProperty(HTTPConstants.HEADER_COOKIE);
StringBuffer cookiesBuffer;
if (cookies == null) {
cookiesBuffer = new StringBuffer();
} else {
cookiesBuffer = new StringBuffer(cookies);
}
if (cookiesBuffer.length() != 0) {
cookiesBuffer.append(";");
}
cookiesBuffer.append("CCCC=cccc");
call.setProperty(
HTTPConstants.HEADER_COOKIE,
cookiesBuffer.toString());
Geoff Alexander, Ph.D.
919/254-5216 T/L 444-5216
SDWB Development
IBM Corporation
RTP, NC
----- Forwarded by Geoff Alexander/Raleigh/IBM on 06/09/2003 02:02 PM -----
Geoff Alexander
To: "Simon Solomon" <[EMAIL
PROTECTED]>
06/07/2003 09:24 cc: [EMAIL PROTECTED]
PM From: Geoff Alexander/Raleigh/[EMAIL
PROTECTED]
Subject: Re: Setting HTTP Headers in
WSIF SOAP over HTTP requests(Document link: Geoff
Alexander)
Simon,
I'm now able to include HTTP headers in my WSIF requests based on your
sample code. However, I am unable to send a send a Cookie header. For
example, the following code sends the cookie3 header, but not the cookie
header:
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service = factory.getService(def);
WSIFPort port = service.getPort();
WSIFMessage portContext = port.getContext();
if (portContext == null ) {
portContext = new WSIFDefaultMessage();
}
Hashtable httpHeaders;
try {
httpHeaders = (Hashtable) portContext.getObjectPart(
WSIFConstants.CONTEXT_REQUEST_HTTP_HEADERS);
} catch (WSIFException e) {
httpHeaders = null;
}
if (httpHeaders == null) {
httpHeaders = new Hashtable(2);
}
String cookie = (String) httpHeaders.get("cookie");
StringBuffer cookieBuffer = new StringBuffer();
if ((cookie != null) && (!cookie.equals(""))) {
cookieBuffer.append(cookie);
cookieBuffer.append(";");
}
cookieBuffer.append("AAAA=");
cookieBuffer.append("xxxxx");
httpHeaders.put("cookie", cookieBuffer.toString());
httpHeaders.put("cookie3", cookieBuffer.toString());
portContext.setObjectPart(
WSIFConstants.CONTEXT_REQUEST_HTTP_HEADERS,
httpHeaders);
port.setContext(portContext);
WSIFOperation operation = port.createOperation("getUserInfo");
WSIFMessage input = operation.createInputMessage();
WSIFMessage output = operation.createOutputMessage();
WSIFMessage fault = operation.createFaultMessage();
if (operation
.executeRequestResponseOperation(input, output, fault)) {
System.out.println(output.getObjectPart("result"));
} else {
// handle failure
}
Do you know how to include cookies in the WSIF SOAP request?
Geoff Alexander, Ph.D.
919/254-5216 T/L 444-5216
SDWB Development
IBM Corporation
RTP, NC
"Simon Solomon"
<[EMAIL PROTECTED]> To: Geoff
Alexander/Raleigh/[EMAIL PROTECTED]
cc: [EMAIL PROTECTED]
05/20/2003 12:00 Subject: Re: Setting HTTP Headers in
WSIF SOAP over HTTP requests
PM
Geoff,
the attached code sample sets HTTP header(s) to the WSIF Port (which
will be used to execute a service)
org.apache.wsif.WSIFPort wsifPort = null;
//Acquire your port obj...
//Get the Port Context
org.apache.wsif.WSIFMessage portCtx = wsifPort.getContext();
if(null == portCtx)
portCtx = new org.apache.wsif.base.WSIFDefaultMessage();
//Build the header
Hashtable httpHeaders = new Hashtable();
//Add header info (Header Name/Value pair)
httpHeaders.put("Some Header1", "Some header1 value");
httpHeaders.put("Some Header2", "Some header2 value");
//Set The SOAP HTTP Request Header to the port context
portCtx.setObjectPart(
org.apache.wsif.WSIFConstants.CONTEXT_REQUEST_HTTP_HEADERS,
httpHeaders);
wsifPort.setContext(portCtx);
//Use the port Object to execute your service i.e.
//org.apache.wsif.WSIFOperation wsifOperation = wsifPort
().createOperation("myOpName");
Simon Solomon
[EMAIL PROTECTED]
Geoff Alexander
<[EMAIL PROTECTED]>
To
05/20/2003 11:24 AM [EMAIL PROTECTED]
cc
Subject
Setting HTTP Headers in WSIF SOAP
over HTTP requests
Simon,
I'm resending this as I didn't include a subject the first time and thought
you might delete it thinking it was spam.
In an April 4 posting to the wsif-user mailing list, you state:
I am successfully setting HTTP headers for SOAP over HTTP requests.
Could you tell me how you do this?
Thanks,
Geoff Alexander, Ph.D.
919/254-5216 T/L 444-5216
SDWB Development
IBM Corporation
RTP, NC
Geoff Alexander, Ph.D.
919/254-5216 T/L 444-5216
SDWB Development
IBM Corporation
RTP, NC