シンプルな XML をサービスにポストするシンプルな WCF POST があります。
これがサービス契約です。
[ServiceContract]
public interface ITest
{
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "PostTest")]
Stream PostTest(Stream testInfo);
}
そして、構成、空想は何もありません。
<system.serviceModel>
<services>
<service name="T.Test" behaviorConfiguration="ServiceBehaviour">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="webHttpBinding" contract="T.ITest" behaviorConfiguration="web">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
コンテンツ タイプについて言及しない限り、単純なクライアントからテストするとすべてが機能します。
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "text/xml; charset=utf-8";
var xmlDoc = new XmlDocument { XmlResolver = null };
xmlDoc.Load("../../PostData.xml");
string sXml = xmlDoc.InnerXml;
Console.Write(sXml + Environment.NewLine + Environment.NewLine);
req.ContentLength = sXml.Length;
var sw = new StreamWriter(req.GetRequestStream());
sw.Write(sXml);
sw.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
いくつかの調査の後、これは SOAP 1.1 と SOAP 1.2 の間の互換性の問題であることがわかりました。しかし、サーバー側でこれを修正するにはどうすればよいですか?