i have biztalk 2013 app (not r2) needs send json document external vendor's restful api. vendor requires 3 http headers:
content-type: application/json
date: in iso8601 utc format
authorization: custom auth. using constructed string includes above date value run through hmacsha1 hash
in biztalk, outbound (xml) message goes send port, there custom pipeline component transforms json using json.net. far, good. add headers unique per message, created wcf behavior extension implements iclientinspector , iendpointbehavior. in beforesendrequest(), reference httprequestmessageproperty request.
i can add headers collection contenttype header , authorization header. cannot add date header - no errors, no header value when examining fiddler.
i read somewhere date restricted header , workaround use reflection around it. e.g.
methodinfo primethod = headers.gettype().getmethod("addwithoutvalidate", bindingflags.instance | bindingflags.nonpublic); primethod.invoke(headers, new[] { "date", isodatetimestamp }); that didn't work either. i'm stumped with: 1. why no date header @ on request? 2. if there one, how manipulate need give "restricted"?
i tried 2 different options: wcf behavior extension:
public object beforesendrequest(ref message request, system.servicemodel.iclientchannel channel) { system.diagnostics.debug.print("entering beforesendrequest()"); try { httprequestmessageproperty httprequest = null; if (request.properties.containskey(httprequestmessageproperty.name)) { httprequest = request.properties[httprequestmessageproperty.name] httprequestmessageproperty; } webheadercollection headers = httprequest.headers; headers.add(httprequestheader.contenttype, "application/json"); headers.add(string.format("{0}:{1}", "date", _taxwarehelper.isodatetimestamp)); headers.add("twedate", _taxwarehelper.isodatetimestamp); headers.add(httprequestheader.authorization, _taxwarehelper.authorizationstring); and custom pipeline component in send pipeline
string httpheadervalue = new stringbuilder() .append("content-type: application/json") .append("\n") //.append(string.format("date:{0}", taxwarehelper.isodatetimestamp)) //.append("\n") .append(string.format("date:{0}", "fri, 10 jul 2015 08:12:31 gmt")) .append("\n") .append(string.format("twedate:{0}", taxwarehelper.isodatetimestamp)) .append("\n") .append(string.format("authorization:{0}", taxwarehelper.authorizationstring)) .tostring(); pinmsg.context.write("httpheaders", "http://schemas.microsoft.com/biztalk/2006/01/adapters/wcf-properties", httpheadervalue); in either case, can set content-type, authorization , test date - twedate test, can not set actual date header.
yes indeed date special http header respresents date , time @ message originated doesn't prevent using it. date has in rfc 822 format tue, 15 nov 1994 08:12:31 gmt
thing why make hard way coding behaviour while use httpheaders add custom header in custom pipeline component plus cleaner
so try convert date in correct format or use httpheaders
http://www.codit.eu/blog/2013/04/30/using-httpheaders-with-wcf-webhttp-adapter-on-biztalk-2013/ http://www.w3.org/protocols/rfc2616/rfc2616-sec14.html
Comments
Post a Comment