生成的wsdl文件包含奇怪的消息名称.WCF
本文关键字:消息 WCF wsdl 文件包 | 更新日期: 2023-09-27 18:14:17
在生成的wsdl文件(形式WCF服务)中有一个奇怪的名称模板(可能只适合我)。例如描述方法的部分:
<wsdl:message name="InterfaceName_MethodName_InputMessage">
<wsdl:part name="parameters" element="tns:MethodName"/>
</wsdl:message>
如何强制WCF不生成InterfaceName前缀和InputMessage后缀?OutputMessage情况也是如此。我希望wsdl看起来如下所示:
<wsdl:message name="MethodName">
<wsdl:part name="parameters" element="tns:MethodName"/>
</wsdl:message>
您可以使用MessageContract更改消息元素。假设接口中的方法是这样的:
<OperationContract>
Function methodName(param as String) as Integer
那么你必须把它改成:
<OperationContract>
Function methodName(param As messageInput) As mesageOutput
添加这些类:
<MessageContract()> _
Public Class messageInput
Private input1 As String
<DataMember(Name:="input")> _
Public Property input() As String
Get
Return Me. input1
End Get
Set(ByVal value As String)
Me. input1 = value
End Set
End Property
End Class
<MessageContract()> _
Public Class mesageOutput
Private return1 As Integer
<DataMember(Name:="return")> _
Public Property return() As Integer
Get
Return Me. return1
End Get
Set(ByVal value As Integer)
Me. return1 = value
End Set
End Property
End Class
现在你的message元素变成了:
<wsdl:operation name="methodName">
<wsdl:input message="messageInput"/>
<wsdl:output message="messageOutput">
</wsdl:operation>
Edit1:
要更改方法名和action属性,请在接口中执行:
<OperationContractAttribute(Action:="actionName", name:="manipulateMethodName" ReplyAction:="actionResonseName")> _
Function methodName(param As messageInput) As mesageOutput