IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Retrieving HTTP headers in custom content handler

  • 1.  Retrieving HTTP headers in custom content handler

    Posted Mon December 12, 2005 04:58 AM

    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.


    #webmethods-Protocol-and-Transport
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Retrieving HTTP headers in custom content handler

    Posted Mon December 12, 2005 05:14 AM

    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


    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport
    #webMethods


  • 3.  RE: Retrieving HTTP headers in custom content handler

    Posted Tue December 13, 2005 04:21 PM

    Ivan,

    If you are using Reverse Invoke Server, the RI server strips header information for security reasons. Only the content is available.


    #webMethods
    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport


  • 4.  RE: Retrieving HTTP headers in custom content handler

    Posted Mon March 06, 2006 11:32 PM

    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]


    #Integration-Server-and-ESB
    #webMethods
    #webmethods-Protocol-and-Transport