我一直在調查幾天,根據我的供應商,我的SOAP請求不正確,以及我如何更改它。內容類型的WCF中缺少動作SOAP調用HTTP標頭
我也跟着下面的步驟來創建我的SOAP客戶端:
- 添加服務引用到我的項目。該服務的WSDL是:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="vz801802Service" targetNamespace="http://schemas.vecozo.nl/VZ801802/v1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://schemas.vecozo.nl/VZ801802/v1" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<wsp:Policy wsu:Id="vz801802Soap12_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="true"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="vz801802Soap11_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="true"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xsd:schema targetNamespace="http://schemas.vecozo.nl/VZ801802/v1/Imports">
<xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd0" namespace="http://schemas.vecozo.nl/VZ801802/v1"/>
<xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd2" namespace="http://schemas.vecozo.nl/VZ801802/v1/messages"/>
<xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd3" namespace="http://schemas.vecozo.nl/VZ801802/v1/types"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="vz801802Service_Controleer_InputMessage">
<wsdl:part name="parameters" element="tns:Controleer"/>
</wsdl:message>
<wsdl:message name="vz801802Service_Controleer_OutputMessage">
<wsdl:part name="parameters" element="tns:ControleerResponse"/>
</wsdl:message>
<wsdl:portType name="vz801802Service">
<wsdl:operation name="Controleer">
<wsdl:input wsaw:Action="http://schemas.vecozo.nl/VZ801802/v1/Controleer" message="tns:vz801802Service_Controleer_InputMessage"/>
<wsdl:output wsaw:Action="http://schemas.vecozo.nl/VZ801802/v1/Controleer/reply" message="tns:vz801802Service_Controleer_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="vz801802Soap12" type="tns:vz801802Service">
<wsp:PolicyReference URI="#vz801802Soap12_policy"/>
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Controleer">
<soap12:operation soapAction="http://schemas.vecozo.nl/VZ801802/v1/Controleer" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="vz801802Soap11" type="tns:vz801802Service">
<wsp:PolicyReference URI="#vz801802Soap11_policy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Controleer">
<soap:operation soapAction="http://schemas.vecozo.nl/VZ801802/v1/Controleer" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="vz801802Service">
<wsdl:port name="vz801802Soap12" binding="tns:vz801802Soap12">
<soap12:address location="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc"/>
</wsdl:port>
<wsdl:port name="vz801802Soap11" binding="tns:vz801802Soap11">
<soap:address location="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc/soap11"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
這創造了代理類我。
接下來我調整我的app.config一點,迫使它使用SOAP1.2(所以我刪除了SOAP1.1項,因爲這些問題我有)
<?xml version="1.0"?> <configuration> <system.serviceModel> <bindings> <customBinding> <binding name="vz801802Soap12"> <textMessageEncoding messageVersion="Soap12" /> <httpsTransport requireClientCertificate="true" /> </binding> </customBinding> </bindings> <client> <endpoint address="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc" binding="customBinding" bindingConfiguration="vz801802Soap12" contract="COV_VZ801802.vz801802Service" name="vz801802Soap12" /> </client> </system.serviceModel> </configuration>
的代碼實例化和調用web服務是:
WSHttpBinding serviceBinding = new WSHttpBinding(SecurityMode.Transport); serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; serviceBinding.ReceiveTimeout = new TimeSpan(0, 0, 120);
EndpointAddress endpointAddress = new EndpointAddress(Bericht.Url); COV_VZ801802.vz801802ServiceClient VZ801_Client = new COV_VZ801802.vz801802ServiceClient(serviceBinding, endpointAddress);
if (Bericht.Certificaat != null && Bericht.Certificaat != "") { X509Certificate2 x509_2 = new X509Certificate2(Bericht.Certificaat); VZ801_Client.ClientCredentials.ClientCertificate.Certificate = x509_2; }
COV_VZ801802.ControleerRequestType VZ801_Request = new COV_VZ801802.ControleerRequestType();
// Here I fill request with data
COV_VZ801802.ControleerResponseType VZ801_Reponse = VZ801_Client.Controleer(VZ801_Request);當檢查與小提琴手的消息時,我看到以下內容:
POST
https://acccovwebservice.vecozo.nl/v1/VZ801802.svc
HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 Host: acccovwebservice.vecozo.nl Content-Length: 1216 Expect: 100-continue Accept-Encoding: gzip, deflate Connection: Keep-Alive<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> <a:Action s:mustUnderstand="1">
http://schemas.vecozo.nl/VZ801802/v1/Controleer
</a:Action> <a:MessageID>urn:uuid:a492c393-a93b-43df-9f0e-4e3f7116f8a2</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous
</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">https://acccovwebservice.vecozo.nl/v1/VZ801802.svc
</a:To> </s:Header> <s:Body> <Controleer xmlns="http://schemas.vecozo.nl/VZ801802/v1"> <request xmlns:b="http://schemas.vecozo.nl/VZ801802/v1/messages" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <b:Zorgaanbieder i:nil="true" xmlns:c="http://schemas.vecozo.nl/VZ801802/v1/types"/> <b:Zoekopdrachten xmlns:c="http://schemas.vecozo.nl/VZ801802/v1/types"> <c:Zoekopdracht> <c:Volgnummer>0</c:Volgnummer> <c:Geboortedatum>1956-01-14</c:Geboortedatum> <c:Peildatum>2013-05-08</c:Peildatum> <c:Bsn i:nil="true"/> <c:Verzekerdenummer>FB_60585</c:Verzekerdenummer> <c:Postcode i:nil="true"/> <c:ReferentieZorgaanbieder i:nil="true"/> <c:Huisnummer i:nil="true"/> <c:Huisnummertoevoeging i:nil="true"/> </c:Zoekopdracht> </b:Zoekopdrachten> </request> </Controleer> </s:Body> </s:Envelope>
運行程序時,我得到一個異常,告訴我:
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
供應商告訴我,他看到了這個消息,兩個問題:
- 有沒有在內容類型定義的動作的標題。內容類型應該是
application/soap+xml;charset=UTF-8;action="http://schemas.vecozo.nl/VZ801802/v1/Controleer"
- mustUnderstand屬性的兩個值(以行動和標記)應該是0而不是1
我一直在尋找和搜索所有類型的地方,嘗試自定義頭部等,等等,但我還沒有找到解決這些問題的方法。
任何人都可以幫助我嗎?我非常絕望,因爲我需要在6月1日之前解決這個問題。
順便說一句,我使用.NET 4.0 BTW2我使用的Visual Studio Express的2012年Windows桌面編輯我的項目
編輯:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="schemas.vecozo.nl/VZ801802/v1";, ConfigurationName="COV_VZ801802.vz801802Service")]
public interface vz801802Service
{
[System.ServiceModel.OperationContractAttribute(Action="schemas.vecozo.nl/VZ801802/v1/Controleer";, ReplyAction="schemas.vecozo.nl/VZ801802/v1/Controleer/reply")]
SOAPLib.COV_VZ801802.ControleerResponseType Controleer(SOAPLib.COV_VZ801802.ControleerRequestType request);
}
請分享您的違約操作合同的合同定義。 – Chris 2013-05-08 11:21:59
您的意思是代理代碼:[System.CodeDom.Compiler.GeneratedCodeAttribute(「System.ServiceModel」,「4.0.0.0」)] [System.ServiceModel.ServiceContractAttribute(Namespace =「http://schemas.vecozo.nl/ VZ801802/V1" ,ConfigurationName = 「COV_VZ801802.vz801802Service」)] 公共接口vz801802Service { [System.ServiceModel.OperationContractAttribute(動作= 「http://schemas.vecozo.nl/VZ801802/v1/Controleer」,ReplyAction = 「http://schemas.vecozo.nl/VZ801802/v1/Controleer/reply」)] SOAPLib.COV_VZ801802.ControleerResponseType Controleer(SOAPLib.COV_VZ801802.ControleerRequestType request); } – 2013-05-08 11:54:01
「1.在頭文件的內容類型中沒有定義任何操作......」剛纔看了一下我的WCF 4應用程序,確實沒有這些信息就能正常工作。 – 2013-05-08 14:29:01