我正尝试使用WCF构建Web服务。由于该服务最终将被非.NET语言使用,因此我一直试图使用“添加Web引用”或使用WSDL.exe而不是svcutil方式对其进行测试。我一直在收到以下错误:WCF Web服务 - 无法构建代理类
从WSDL.exe - 错误:无法从命名空间http://tempuri.org导入绑定BasicHttpBinding_IEchoService。 - - 无法导入操作Echo。 - - 元素http://tempuri.org/:Echo缺失。
从添加服务引用和添加Web引用: 元数据包含无法解析的引用:链接到wsdl。 WSDL文档包含无法解析的链接。下载时出现错误http://localhost:8080/EchoService.svc?xsd=xsd0 底层连接已关闭。
此简化示例与主要服务具有相同的问题。
这里的服务的Web.Config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="EchoBehaviorConfiguration">
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="EchoService">
<endpoint address=""
behaviorConfiguration="EchoBehaviorConfiguration"
binding="basicHttpBinding"
contract="IEchoService" />
<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" />
</service>
</services>
<bindings>
<basicHttpBinding>
</basicHttpBinding>
<mexHttpBinding></mexHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
这里的合同/接口:
[ServiceContract]
public interface IEchoService
{
[OperationContract]
string Echo(string message);
}
而这里所生成的WSDL:
<wsdl:definitions name="EchoService" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:8080/EchoService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost:8080/EchoService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IEchoService_Echo_InputMessage">
<wsdl:part name="parameters" element="tns:Echo"/>
</wsdl:message>
<wsdl:message name="IEchoService_Echo_OutputMessage">
<wsdl:part name="parameters" element="tns:EchoResponse"/>
</wsdl:message>
<wsdl:portType name="IEchoService">
<wsdl:operation name="Echo">
<wsdl:input wsaw:Action="http://tempuri.org/IEchoService/Echo" message="tns:IEchoService_Echo_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IEchoService/EchoResponse" message="tns:IEchoService_Echo_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IEchoService" type="tns:IEchoService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Echo">
<soap:operation soapAction="http://tempuri.org/IEchoService/Echo" 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="EchoService">
<wsdl:port name="BasicHttpBinding_IEchoService" binding="tns:BasicHttpBinding_IEchoService">
<soap:address location="http://localhost:8080/EchoService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
该服务目前通过IIS7在本地托管。我尝试了HTTP和HTTPS,并有相同的问题。如果我试图改变从basicHttpBinding到webHttpBinding的绑定,WSDL中没有任何变化。
关于我要去哪里的任何想法都是错误的?
更新: 我有配置现在设置,如果该服务运行在卡西尼而不是IIS下,我可以添加服务或Web引用到我的测试项目。我不能保存wsdl并使用WSDL.exe来生成代理类。
所以现在我有3个问题:
除了做一个ASPNET_REGIIS安装和使用IIS注册WCF 4,有什么事我可以有什么关系?
任何想法我需要做什么才能使它与WSDL.exe一起工作?
执行ASMX服务并比较生成的WSDL后,它们会有很大的不同,这让我质疑WCF在这一点上与非.NET语言的兼容性。
+1这是我的问题。干杯! – ashes999 2011-11-04 14:15:44