繁体   English   中英

如何在WCF 4.0服务方法中使用SOAPAction获得响应?

[英]How to get response with SOAPAction in WCF 4.0 Service method?

我有一个Web服务方法,可以返回以下响应而无需(SOAPAction:“”)

方法

public string SyncData(Stream xml)
{

}

web.config

<service behaviorConfiguration="" name="PRO.API">
    <endpoint address="" behaviorConfiguration="web" binding="customBinding"
     bindingConfiguration="RawReceiveCapable" contract="PRO.IAPI" />
</service>

customBinding

<customBinding>    
<binding name="RawReceiveCapable">
<webMessageEncoding webContentTypeMapperType="PRO.RawContentTypeMapper, PRO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
</binding>
</customBinding>

public class RawContentTypeMapper : WebContentTypeMapper
{
    public override WebContentFormat GetMessageFormatForContentType(string contentType)
    {

        if (contentType.Contains("text/xml")
            || contentType.Contains("application/xml")
            || contentType.Contains("text/html"))
        {

            return WebContentFormat.Raw;

        }

        else
        {

            return WebContentFormat.Default;

        }
    }
}

SOAPAction的必需响应:“”

内容类型:text / xml; charset = utf-8内容长度:346 SOAPAction :“”

<soapenv:Envelope" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<syncOrderRelationResponse xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">
<result>0</result>
<resultDescription>success</resultDescription>
</syncOrderRelationResponse>
</soapenv:Body>
</soapenv:Envelope>

感谢adavnce,我应该怎么做才能获得SOAPAction的响应?

请参阅此链接以获取“样本SOAP响应” http://support.sas.com/documentation/cdl/zh-CN/wbsvcdg/62759/HTML/default/viewer.htm#n1wblekhip1yrln1fv2s5b6a2d9f.htm

您可以在OperationContract属性中指定Action属性。 检查此问题如何为WCF指定自定义SoapAction

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM