我们如何知道 wcf 服务的输入/输出类型


How can we know the input/output type of wcf service?

我是WCF的新手,我在wcf中编写了一些服务。 它现在发布在内联网上,一些应用程序已经在使用该服务。 目前,我必须为其他开发人员制作有关输入参数/数据类型和输出参数的文档。 如果我们使用 .Net 平台来使用服务,这没关系。 它会自动在WebReferences文件夹中创建服务/类,并且智能感知可以完美地工作。

但是如果用户使用的是PHP或经典ASP,则它不会以这种方式工作。 他们必须知道确切的名称,参数的类型,我必须非常仔细地记录服务。

通过使用WSDL,如下所示:我们如何知道要使用的服务的数据类型和参数? 如果它没有显示在 WSDL 中,我应该在哪里查看这些信息? 如果有人在没有文档的情况下向我提供了 WCF 服务,我怎么知道如何使用该服务?

非常感谢。

这是我关于服务的界面

[ServiceContract]
public interface IEmail
{
    [OperationContract]
    bool InsertEmail(string Subject, string SentFrom, string SentTo, int ApplicationID, int TemplateID, string DataText);
}

以下是有关我的服务的确切 WSDL 信息。

    <?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions name="Email" targetNamespace="http://tempuri.org/" 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://tempuri.org/" 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/">
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
  <xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd0" namespace="http://tempuri.org/" /> 
  <xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
  </xsd:schema>
  </wsdl:types>
- <wsdl:message name="IEmail_InsertEmail_InputMessage">
  <wsdl:part name="parameters" element="tns:InsertEmail" /> 
  </wsdl:message>
- <wsdl:message name="IEmail_InsertEmail_OutputMessage">
  <wsdl:part name="parameters" element="tns:InsertEmailResponse" /> 
  </wsdl:message>
- <wsdl:portType name="IEmail">
- <wsdl:operation name="InsertEmail">
  <wsdl:input wsaw:Action="http://tempuri.org/IEmail/InsertEmail" message="tns:IEmail_InsertEmail_InputMessage" /> 
  <wsdl:output wsaw:Action="http://tempuri.org/IEmail/InsertEmailResponse" message="tns:IEmail_InsertEmail_OutputMessage" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="BasicHttpBinding_IEmail" type="tns:IEmail">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="InsertEmail">
  <soap:operation soapAction="http://tempuri.org/IEmail/InsertEmail" 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="Email">
- <wsdl:port name="BasicHttpBinding_IEmail" binding="tns:BasicHttpBinding_IEmail">
  <soap:address location="http://myservice/Email.svc" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

如果您的意思是看不到服务在 WSDL 中使用的所有类型,这是因为 WSDL WCF 创建的 WSDL 通常(可能总是)拆分为几个位。这些其他位从主 WSDL 链接到。

因此,如果您浏览到 http://myservice/Email.svc?wsdl ,您将看到您在问题中输入的 WSDL。在这里,您可以看到指向其他两个架构的链接 - http://myservice/Email.svc?xsd=xsd0http://myservice/Email.svc?xsd=xsd1 。如果您浏览到这些,您将找到您要查找的类型信息。