我已經查看了將HTTP頭添加到SOAP請求的答案,並找到了一些好的並使用了代碼。我想我在附加的代碼中擁有一切,但是當我在Fiddler中查看請求時,看不到任何頭文件被添加。有人可以看看我在這裏是否缺少東西嗎?謝謝。這是一項PeopleSoft服務。不能將HTTP頭添加到SOAP請求中
UTZ_EMP_BIO_INFO_PortTypeClient utz = new UTZ_EMP_BIO_INFO_PortTypeClient();
UTZ_EMP_BIO_INFO_PortType utShare = utz;
using (System.ServiceModel.OperationContextScope scope = new System.ServiceModel.OperationContextScope((IContextChannel)utz.InnerChannel))
{
MessageHeaders messageHeadersElement = System.ServiceModel.OperationContext.Current.OutgoingMessageHeaders;
messageHeadersElement.Add(MessageHeader.CreateHeader("SOAPAction", String.Empty, "UTZ_EMP_BIO_INFO.v1"));
Console.WriteLine("down under");
SendEmpBioRespV1 resp = default(SendEmpBioRespV1);
rqst.GetEmpBioInfoReq.GetEmpBioInfo.UTZ_EMP_SRCH_VW.SSN = "123456789";
rqst.GetEmpBioInfoReq.GetEmpBioInfo.UTZ_EMP_SRCH_VW.EMPLID = "";
resp = utShare.UTZ_EMP_BIO_INFO(rqst);
Console.WriteLine(resp.SendEmpBioResp.SendEmpBioInfo.UTZ_EMP_BIO_WRK.CITY);
}
什麼是'HttpWebRequest'有什麼關係? –
我想我假設這個問題是關於「添加HTTP頭到SOAP請求」,我會使用'HttpWebRequest'來處理SOAP請求。 http://stackoverflow.com/questions/2434703/using-the-httpwebrequest-class 也許我錯誤地理解了這個問題,如果我這樣做了,我很抱歉。如果它不適合你,請不要選擇/投票。你會推薦約翰嗎? –
@JohnSaunders?爲先前的評論。 –