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

标签 c# php wcf

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

但是如果用户使用 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 中使用的所有类型,这是因为 WCF 创建的 WSDL 通常(也许总是)被分成几个位。这些其他位链接到主 WSDL。

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

关于c# - 我们如何知道wcf服务的输入/输出类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11987468/

相关文章:

php - php 中的 xml 解析 - 获取特定值

javascript - 如何在浏览器上点击后退按钮和页面刷新后重新更新查询

.net - 无法为 SOAP 调用的 SSL/TLS 建立安全通道

c# - WCF 中的 SOAP 消息反序列化问题 - 字段具有空值

c# - 如何从日期时间中减去一年零一天?

C# 对象构造函数 - 简写属性语法

c# - PostMessage 不适用于其输出被重定向和异步读取的控制台窗口

php 表单 Action php self

c# - 使用列表邮件时,Outlook 邮件 API 返回拼写检查类名称作为 html 响应的一部分

c# - WCF,生成的DataMember List<>代理类属性为null?