1
微软MSDN描述为WCF普遍服务合同和WS-互操作合规
[ServiceContract]
public interface IUniversalRequestReply
{
[OperationContract(Action="*", ReplyAction="*")]
Message ProcessMessage(Message msg);
}
为请求应答操作的最普遍的服务合同。如果我做类似下面的一个合同,使用basicHttp约束力,也不会符合WS-I(使用SOAPUI合规性检查)。
[OperationContract]
Message SomeOperation(Message msg);
我认为最普遍的合同也是最具有互操作性的。
任何人都可以解释为什么它不符合WS-I?更重要的是 - 使用Message类会使服务对Java客户端来说更少消耗?
任何使用Message类的经验值得赞赏。
编辑第一个答案后:
这是表示该服务合同,经营合同的全部WSDL。
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="UniversalRequestReply" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:52437/UniversalRequestReply.svc?xsd=xsd0" namespace="http://schemas.microsoft.com/Message"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IUniversalRequestReply_SomeOperation_InputMessage">
<wsdl:part xmlns:q1="http://schemas.microsoft.com/Message" name="msg" type="q1:MessageBody"/>
</wsdl:message>
<wsdl:message name="IUniversalRequestReply_SomeOperation_OutputMessage">
<wsdl:part xmlns:q2="http://schemas.microsoft.com/Message" name="SomeOperationResult" type="q2:MessageBody"/>
</wsdl:message>
<wsdl:portType name="IUniversalRequestReply">
<wsdl:operation name="SomeOperation">
<wsdl:input wsaw:Action="http://tempuri.org/IUniversalRequestReply/SomeOperation" message="tns:IUniversalRequestReply_SomeOperation_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IUniversalRequestReply/SomeOperationResponse" message="tns:IUniversalRequestReply_SomeOperation_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IUniversalRequestReply" type="tns:IUniversalRequestReply">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SomeOperation">
<soap:operation soapAction="http://tempuri.org/IUniversalRequestReply/SomeOperation" 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="UniversalRequestReply">
<wsdl:port name="BasicHttpBinding_IUniversalRequestReply" binding="tns:BasicHttpBinding_IUniversalRequestReply">
<soap:address location="http://localhost:52437/UniversalRequestReply.svc/basic"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
什么WSI一致性测试失败不是缺少服务合同,但消息本身输入:
Name of message that failed: {http://tempuri.org/}IUniversalRequestReply_SomeOperation_InputMessage
Message: name={http://tempuri.org/}IUniversalRequestReply_SomeOperation_InputMessage
Part: name=msg
typeName={http://schemas.microsoft.com/Message}MessageBody
所以利用这个消息类是不符合节水灌溉的一些原因。
经过一番思考,我猜你的意思是数据合同而不是服务合同,在你的答案的第一行。由于该服务除了一个对反序列化有用的数据合约外, – fanvabra 2012-08-22 09:00:10
我的意思是服务合同,因为它定义了操作和数据合同。在“通用”合同的情况下,针对任何可能的操作调用单个方法。该方法需要解析调用的操作和适用于该方法的相应数据协定。是的,通用服务对请求/响应的序列化和反序列化负责。 – 2012-08-22 12:50:15