मैं WCF सीख रहा हूँ, विशेष रूप से मैं उन्हें अनुबंध पहले लिखने के लिए कैसे सीख रहा हूँ आला wscf.blueमुझे अपने डब्ल्यूसीएफ क्लाइंट/सेवा के लिए ActionNotSupportedException क्यों मिलता है?
मैं एक WCF क्लाइंट/सेवा अनुबंध पिछले रास्ता (माइक्रोसॉफ्ट) मैं एक WCF क्लाइंट/सेवा बना सकते हैं बना सकते हैं अनुबंध पहला तरीका (डब्ल्यूएससीएफ)
लेकिन, अगर मैं अनुबंध पहली सेवा बनाता हूं, तो इसे WSCF.blue तरीके (अनुबंध साझा करें और क्लाइंट उत्पन्न करें) के बजाय इसे माइक्रोसॉफ्ट तरीका (सेवा संदर्भ) जोड़ने का प्रयास करें। टी काम नहीं
यह संदेश The message with Action 'urn:test-com:simple:testMethodIn' 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).
के साथ एक ActionNotSupportedException
फेंकता है और मैं पता नहीं कि क्या मतलब है।
SimpleModel.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="urn:test-com:simple" xmlns:mstns="urn:test-com:simple" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:test-com:simple" elementFormDefault="qualified" attributeFormDefault="unqualified" id="SimpleModel">
<xs:complexType name="PayloadType">
<xs:sequence>
<xs:element name="AString" type="xs:string" nillable="1" minOccurs="0"/>
<xs:element name="AnInt" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
SimpleMessages.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="urn:test-com:simple" xmlns:mstns="urn:test-com:simple" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:smod="http://tempuri.org/SimpleModel.xsd" targetNamespace="urn:test-com:simple" elementFormDefault="qualified" attributeFormDefault="unqualified" id="SimpleMessages">
<xs:include schemaLocation="SimpleModel.xsd"/>
<xs:element name="TestMethod">
<xs:complexType>
<xs:sequence>
<xs:element name="APayload" type="PayloadType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TestMethodResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Output" type="PayloadType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Simple.wsdl
<!--WSDL generated by thinktecture WSCF; version 1.0.13.0-->
<!--Tuesday, 09-10-2012 - 02:41 PM-->
<definitions xmlns:tns="urn:test-com:simple" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" name="Simple" targetNamespace="urn:test-com:simple">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
<types>
<xsd:schema>
<xsd:import schemaLocation="SimpleMessages.xsd" namespace="urn:test-com:simple"/>
</xsd:schema>
</types>
<message name="testMethodIn">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
<part name="parameters" element="tns:TestMethod"/>
</message>
<message name="testMethodOut">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
<part name="parameters" element="tns:TestMethodResponse"/>
</message>
<portType name="SimpleInterface">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
<operation name="TestMethod">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
<input message="tns:testMethodIn"/>
<output message="tns:testMethodOut"/>
</operation>
</portType>
<binding name="BasicHttpBinding_SimpleInterface" type="tns:SimpleInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="TestMethod">
<soap:operation soapAction="urn:test-com:simple:testMethodIn" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ISimple">
<port name="NewPort" binding="tns:BasicHttpBinding_SimpleInterface">
<soap:address location="http://localhost:50862/Simple.svc"/>
</port>
</service>
</definitions>
यहाँ system.serviceModel अनुभाग है:
यहाँ अपने परीक्षण अनुबंध है इधर-उधर मीटर web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehaviour">
<serviceMetadata externalMetadataLocation="http://localhost:50862/TestContract/Simple.wsdl" httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_SimpleInterface" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="SimpleServiceBehaviour" name="SimpleContract.Simple">
<endpoint address="http://localhost:50862/Simple.svc" behaviorConfiguration="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SimpleInterface" contract="ISimple"/>
</service>
</services>
</system.serviceModel>
अगर मैं एक सेवा संदर्भ http://localhost:50862/Simple.svc
को हर ठीक उत्पन्न करने के लिए दिखाई दे।
मैं web.config आयात करके सेवा config संपादक का उपयोग कर ग्राहक app.config में इस बनाने के लिए:
<system.serviceModel>
<client>
<endpoint address="http://localhost:50862/Simple.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SimpleInterface" contract="SI.SimpleInterface" name="NewPort"/>
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_SimpleInterface" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
और अगर मैं अपने परीक्षण कोड चलाएँ:
static void Main(string[] args)
{
SimpleInterfaceClient client = new SimpleInterfaceClient();
var ret = client.TestMethod(new PayloadType() { AnInt = 7, AString = "bob" });
Console.WriteLine(ret.ToString());
Console.ReadLine();
}
TestMethod अंदर निम्न पंक्ति प्रॉक्सी:
return base.Channel.TestMethod(request);
निम्नलिखित अपवाद को फेंकता है
System.ServiceModel.ActionNotSupportedException occurred
Message="The message with Action 'urn:test-com:simple:testMethodIn' 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)."
Source="System.ServiceModel"
StackTrace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
क्या कोई मदद कर सकता है?
धन्यवाद,
जे
पहले संपादित
ठीक है, मैं अब मिल गया है वहाँ कुछ मेरी डॉक से प्रकाशित-लिपटे wsdl और कोड जनरेटर के साथ गलत हो रहा है। wscf.blue को इसके संदेशों को नालीबल के रूप में चिह्नित नलिका प्रकारों को पसंद नहीं है। यह लपेटा मोड से बाहर आता है और विधि कार्यान्वयन अनचाहे नहीं हैं।
लेकिन, अगर मैं उन्हें शून्य के रूप में चिह्नित नहीं करता हूं, तो क्लाइंट कोड रैपिंग मोड से बाहर हो जाता है क्योंकि वे शून्य प्रकार के रूप में चिह्नित नहीं होते हैं।
नल प्रकार के साथ चिह्नित नहीं nillable:
सर्वर साइड:
[System.ServiceModel.OperationContractAttribute(Action="urn:test-com:simple/ISimple/TestMethod", ReplyAction="urn:test-com:simple/ISimple/TestMethodResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[return: System.ServiceModel.MessageParameterAttribute(Name="Output")]
PayloadType TestMethod(PayloadType APayload);
क्लाइंट साइड:
// CODEGEN: Generating message contract since element name APayload from namespace urn:test-com:simple is not marked nillable
[System.ServiceModel.OperationContractAttribute(Action="urn:test-com:simple:testMethodIn", ReplyAction="*")]
DesktopClientTest_ServiceReference.SI.TestMethodResponse TestMethod(DesktopClientTest_ServiceReference.SI.TestMethodRequest request);
नल प्रकार के साथ nillable के रूप में चिह्नित:
सर्वर साइड:
// CODEGEN: Parameter 'Output' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="urn:test-com:simple/ISimple/TestMethod", ReplyAction="urn:test-com:simple/ISimple/TestMethodResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[return: System.ServiceModel.MessageParameterAttribute(Name="Output")]
TestMethodResponse TestMethod(TestMethodRequest request);
क्लाइंट साइड:
[System.ServiceModel.OperationContractAttribute(Action="urn:test-com:simple:testMethodIn", ReplyAction="*")]
[return: System.ServiceModel.MessageParameterAttribute(Name="Output")]
DesktopClientTest_ServiceReference.SI.PayloadType TestMethod(DesktopClientTest_ServiceReference.SI.PayloadType APayload);
हालांकि मैं पता नहीं है कि कारण है कि क्या है, अकेले इसे कैसे ठीक करने के लिए। ने कहा, मैं जानता हूं कि नलिका प्रकारों को डॉक्टर-लिट-लिपटे wsdl के लिए शून्य के रूप में चिह्नित किया जाना चाहिए।