3
我需要使用json主體與SOAP身份驗證頭接口。發送到WCF服務時使用soap信封中的json主體
我創建的合同是這樣的:
[ServiceContract(Namespace = "http://tourico.com/webservices/hotelv3")]
public interface IHotelMobileFlow
{
[OperationContract, WebInvoke(
BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
SearchResultMobile SearchHotels(SearchRequestMobile request);
這樣的服務:爲屬性
[AuthenticationRequired(typeof(HotelFlow), typeof(DefaultClientAuthenticationHandler))]
public class HotelMobileFlow : IHotelMobileFlow
{
'AuthenticationRequired' 我需要發送SOAP頭
<soapenv:Header>
<aut:AuthenticationHeader>
<aut:LoginName>host</aut:LoginName>
<aut:Password>password</aut:Password>
<aut:Culture>en_US</aut:Culture>
<aut:Version>8</aut:Version>
</aut:AuthenticationHeader>
</soapenv:Header>
我創建了這樣的請求:
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
SearchRequestMobile sr = new SearchRequestMobile();
是否可以將soap標頭添加到json請求中? 還有其他選擇如何將標題傳輸到服務?
謝謝Michal