首页 文章

Wcf as soap:不同的问题取决于客户

提问于
浏览
1

我正在开发一个简单的wcf服务,并尝试将其作为Soap公开,出于兼容性原因:客户端将是一个带有漂亮的actionscript的flash应用程序 .

我显然使用basicHttpBinding来生成与soap兼容的WSDL .

以下是我的配置(当然是匿名的敏感数据):

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="soapBinding" />
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="BasicBehavior" name="MyCustomer.MyProject.WebService.MyService">
    <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
    <endpoint binding="basicHttpBinding" bindingConfiguration="soapBinding"
      name="Basic" bindingNamespace="http://myurl"
      contract="MyCustomer.MyProject.WebService.IMyService">
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://myurl" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="BasicBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

真的很简单 . 现在开发Flash应用程序的人声称他有一些麻烦,他看到了唯一存在的方法(称为ValidateForm),但他没有看到参数列表 .

我尝试了以下方法:

  • 使用storm(storm.codeplex.com)调用web服务:小心:风暴而不是wcf风暴 . Storm仅适用于普通的Web服务,无法以本机WCF模式连接 . 这很好用 . 我看到参数,可以填充它们,调用并接收正确的响应 .

  • 使用http://soapclient.com/soaptest.html调用服务:这会读取我的wsdl,查看参数列表,但是在调用"unexpected error"时会发生 .

  • 使用http://www.validwsdl.com/调用Web服务:这会读取wsdl,但根本看不到参数列表,并且调用失败 .

我的服务显然有问题 . 接下来是WSDL,也许有人可以告诉我什么是错的(再次匿名):

<wsdl:definitions name="mycustomermyprojectService" targetNamespace="http://www1.myproject.mydomain.com" 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://www1.myproject.mydomain.com" 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">
  <wsdl:types>
    <xsd:schema targetNamespace="http://www1.myproject.mydomain.com/Imports">
      <xsd:import schemaLocation="http://www1.myproject.mydomain.com/?xsd=xsd0" namespace="http://www1.myproject.mydomain.com"/>
      <xsd:import schemaLocation="http://www1.myproject.mydomain.com/?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
      <xsd:import schemaLocation="http://www1.myproject.mydomain.com/?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/mycustomer.myproject.WebService.Models"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="ImycustomermyprojectService_ValidateForm_InputMessage">
    <wsdl:part name="parameters" element="tns:ValidateForm"/>
  </wsdl:message>
  <wsdl:message name="ImycustomermyprojectService_ValidateForm_OutputMessage">
    <wsdl:part name="parameters" element="tns:ValidateFormResponse"/>
  </wsdl:message>
  <wsdl:portType name="ImycustomermyprojectService">
    <wsdl:operation name="ValidateForm">
      <wsdl:input wsaw:Action="http://www1.myproject.mydomain.com/ImycustomermyprojectService/ValidateForm" message="tns:ImycustomermyprojectService_ValidateForm_InputMessage"/>
      <wsdl:output wsaw:Action="http://www1.myproject.mydomain.com/ImycustomermyprojectService/ValidateFormResponse" message="tns:ImycustomermyprojectService_ValidateForm_OutputMessage"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="Basic" type="tns:ImycustomermyprojectService">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="ValidateForm">
      <soap:operation soapAction="http://www1.myproject.mydomain.com/ImycustomermyprojectService/ValidateForm" 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="mycustomermyprojectService">
    <wsdl:port name="Basic" binding="tns:Basic">
      <soap:address location="http://www1.myproject.mydomain.com/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

任何人都可以解雇一些?谢谢 .

2 回答

  • 0

    在某些情况下,其他平台不了解导入属性,因此我们需要展平我们的wsdl .

    您可以在以下内容中找到有关如何展平wsdl的一些信息link

    您需要创建自己的服务主机工厂,按照链接中的说明展平您的wsdl . 如果我没有错的话,这将是.NET 4.5中的一个内置功能 . 有关的信息可以在link找到

  • 1

    这个wsdl确实没有直接类型 . 它们是从xsd:import声明中的其他位置(例如 http://www1.myproject.mydomain.com/?xsd=xsd0 )导入的 . 解析器必须遵循这些导入并解析它们 . 我不知道validWSDL.com是否这样做 . 我尝试了自己的服务,调用时的错误是:

    “在WSDL文档的元素中找不到匹配的'元素'定义”

    如果您遇到某些客户端的问题,可以尝试直接用这些文件中定义的模式替换导入 . 看看wsdl element identifiers的样子 . 由于我确保这是原因,但您可以尝试使用validwsdl.com并查看它是否有效 . 应该很容易测试 .

相关问题