我正在尝试使用两个端点创建一个wcf服务,一个是SOAP 1.1,另一个是SOAP 1.2。这是我的配置:
<?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
我搞砸了什么?
UPDATE:通过删除wshttpbinding端点并仅在我的配置中使用basichttpbinding端点,我可以获得SOAP 1.1。我需要做些什么才能使两者都可用?
答案 0 :(得分:0)
这是一种方法:
<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
端点的引用,请转到“添加服务引用”屏幕的advanded设置对话框,然后选择“添加Web引用”。
请注意,要生成basicHttpBinding
端点的客户端代理,您必须在添加网络参考时使用http://server/service1.svc和不 http://server/service1.svc/basic/。但是如果你仔细看看客户端上生成的.config文件,你会发现它使用了/ basic / endpoint:
<endpoint address="http://server/Service1.svc/basic/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="Service1Reference.IService1" name="BasicHttpBinding_IService1" />