发送到WCF服务时,在Soap信封中使用json正文
我需要使用json主体与autentication的soap头接口 我创建了如下合同:发送到WCF服务时,在Soap信封中使用json正文,wcf,json,soap,httprequest,Wcf,Json,Soap,Httprequest,我需要使用json主体与autentication的soap头接口 我创建了如下合同: [ServiceContract(Namespace = "http://tourico.com/webservices/hotelv3")] public interface IHotelMobileFlow { [OperationContract, WebInvoke( BodyStyle = WebMessageBodyStyle.Wrapped, RequestF
[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
{
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
SearchRequestMobile sr = new SearchRequestMobile();
这种服务:
[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
{
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
SearchRequestMobile sr = new SearchRequestMobile();
对于“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>
是否可以将soap头添加到json请求中?
还有其他选项如何将标头传输到服务
谢谢,Michal不,不可能将SOAP头添加到JSON请求中。服务将无法解析它。您的web请求定义您正在发送JSON。这意味着请求的内容只能是JSON 理论上,如果您实现自己的消息编码器,您将能够在SOAP正文中发送JSON内容并添加SOAP头,但这种开发的复杂性并不值得 您必须提供其他方式来验证您的客户端。改用自定义HTTP头