[英]What's wrong with my wcf endpoints?
我正在尝试使用两个端点(一个SOAP 1.1和另一个SOAP 1.2)创建一个wcf服务。 这是我的配置:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ProgramInformationWS.Properties.Settings.IMTConnectionString" connectionString="Data Source=DLADD00001;Initial Catalog=IMT;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="EnterpriseReportingWS.ERPService" behaviorConfiguration="ERPService.Behavior">
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="" contract="EnterpriseReportingWS.IERPService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="soap12" binding="wsHttpBinding" bindingConfiguration="" contract="EnterpriseReportingWS.IERPService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://MyServerHere/ERPService/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ERPService.Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
我要在这里配置的是当我点击
http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc/soap
我得到SOAP 1.1,当我点击
http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc/soap12
我得到SOAP 1.2。 但是,我得到的行为是没有一个解决,而我访问服务的唯一方法是从
http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc
我搞砸了什么?
更新:通过删除wshttpbinding端点并仅在配置中使用basichttpbinding端点,我可以获得get SOAP 1.1。 我需要做什么才能使两者都可用?
这是一种方法:
<system.serviceModel>
<services>
<service behaviorConfiguration="Service1Behavior" name="WcfTest.Service1">
<endpoint address="" contract="WcfTest.IService1" binding="wsHttpBinding" />
<endpoint address="/basic/" binding="basicHttpBinding" contract="WcfTest.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
在上面的示例中,我将wsHttpBinding
放在根地址http://server/service1.svc上,而basicHttpBinding
可以在http://server/service1.svc/basic/上找到。 请注意,您将无法在浏览器中看到http://server/service1.svc/basic/ ,但这并不意味着它不存在。
要在Visual Studio中添加对wsHttpBinding
端点的引用,只需像通常那样添加服务引用即可。 要添加对basicHttpBinding
端点的引用,请转到“添加服务引用”屏幕的高级设置对话框,然后选择“添加Web引用”。
请注意,在添加Web参考时,要为basicHttpBinding
端点生成客户端代理,必须使用http://server/service1.svc而不是 http://server/service1.svc/basic/ 。 但是,如果仔细查看客户端上生成的.config文件,您会发现它使用/ basic /端点,如下所示:
<endpoint address="http://server/Service1.svc/basic/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="Service1Reference.IService1" name="BasicHttpBinding_IService1" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.