【发布时间】:2010-09-21 11:59:39
【问题描述】:
我需要与带有 json 主体的 autentication 的肥皂头接口。
我是这样创建合同的:
[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' 我需要发送一个肥皂头
<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请求中? 还有其他选项如何将标头传输到服务?
谢谢,米哈尔
【问题讨论】:
标签: wcf json soap httprequest