0

我使用 DataContract 创建了一个 WCF 服务应用程序,该服务正在生成自己的默认消息名称。Java 客户端正在使用我的服务,我必须摆脱这些默认消息名称,因为它会导致基于这些长名称生成 Java 代理类。

wsdl:message name=" MyService-v1-1_Login_InputMessage "

wsdl:part name="parameters" element="tns:Login"

wsdl:消息

wsdl:message name=" MyService-v1-1_Login_OutputMessage "

wsdl:part name="parameters" element="tns:LoginResponse"

wsdl:消息

wsdl:message name=" MyService-v1-1_Login_ServiceFault_FaultMessage "

wsdl:part name="detail" element="tns:ServiceFault"

4

1 回答 1

1

您可以使用 IWsdlExportExtension 来控制它。请参阅 msdn 上的示例:http: //msdn.microsoft.com/en-us/library/system.servicemodel.description.iwsdlexportextension.aspx

相关代码

            // Get parameter information.
            ParameterInfo[] args = op.SyncMethod.GetParameters();
            for (int i = 0; i < args.Length; i++)
            {
              object[] docAttrs 
                = args[i].GetCustomAttributes(typeof(WsdlParameterDocumentationAttribute), false);
              if (docAttrs.Length != 0)
              {
                // <param name="Int1">Text.</param>
                XmlElement newParamElement = opOwner.CreateElement("param");
                XmlAttribute paramName = opOwner.CreateAttribute("name");
                paramName.Value = args[i].Name;
                newParamElement.InnerText 
                  = ((WsdlParameterDocumentationAttribute)docAttrs[0]).ParamComment;
                newParamElement.Attributes.Append(paramName);
                operation.DocumentationElement.AppendChild(newParamElement);
              }
            }
于 2013-08-06T02:32:59.303 回答