Guest
(Guest)
December 12, 2005, 9:57am
1
Ive created a custom content handler and it is working fine, successfully sending the HTTP Post data to the specified service. However, only the post data is arriving, and the custom HTTP headers are getting lost. How can I access the headers in a name/value fashion.
I have played with ProtocolInfoIf, and it has other fields, but i cant find all the header fields.
I know that the customer headers a being sent by checking TCPMON.
Guest
(Guest)
December 12, 2005, 10:13am
2
to show what i mean, below shows the start of the HTTP transmission, i need to get to all the xyz.protocol header fields
POST /invoke/xyz.services.implementation:HTTPListener HTTP/1.1
Content-Type: application/x-xyz-pki-smime
Connection: keep-alive
xyz.protocol.trackingid: FND8063439cfdaeac00
xyz.protocol.remote.location: FND
xyz.protocol.remote.contenttype: MakePurchase
xyz.protocol.remote.mode: P
xyz.protocol.remote.transmissionGmt: 20051212153350
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.4.2_08
Host: localhost:2222
Accept: text/html, image/gif, image/jpeg, *; q=.2, / ; q=.2
Content-Length: 5750
MIIQYQYJKoZIhvcNAQcCoIIQUjCCEE4CAQExCzAJBgUrDgMCGgUAMIIFWAYJKoZIhvcNAQcB
oIIFSQSCBUUwggVBBgkqhkiG9w0BBwOgggUyMIIFLgIBADGB3zCB3AIBADBFMD0xCzAJBgNV
raymoser
(raymoser *)
December 13, 2005, 9:21pm
3
Ivan,
If you are using Reverse Invoke Server, the RI server strips header information for security reasons. Only the content is available.
IvanG
(IvanG *)
March 7, 2006, 4:32am
4
here is the solution code:
[highlight=java]
public Values getInputValues(InputStream is, InvokeState state){
Values returnValues = new Values();
String requestContent = “”;
String ContentType = state.getContentType();
int i = 0;
byte[] buffer = new byte[2048];
try {
while((i = is.read(buffer)) != -1)
requestContent = requestContent + new String(buffer, 0, i);
is.reset();
} catch (IOException e) {};
com.wm.app.b2b.server.ProtocolInfoIf pi = state.getProtocolInfoIf();
com.wm.net.HttpHeader hd = (com.wm.net.HttpHeader)pi.getProtocolProperty("Req_Header");
String[][] HTTPHeaders = new String[hd.getNumFields()][2];
for (int j=0; j < hd.getNumFields(); j++) {
HTTPHeaders[j][0] = hd.getFieldName(j);
HTTPHeaders[j][1] = hd.getFieldValue(j);
}
returnValues.put("HTTPHeaders", HTTPHeaders);
returnValues.put(is);
returnValues.put("HOP3Content", requestContent);
returnValues.put("ContentType", ContentType);
return returnValues;
}
[/highlight]