我已经搜索了堆栈和谷歌这个问题,似乎无法找到任何线索
问题: C#.net 4控制台应用程序 调用webservice Web服务是:https和asmx
这是我在应用程序中运行的应用程序非常好的.net 4.5但是因为它运行的服务器是Windows 2003所以我必须降级到.net 4,这就是问题所在
在没有修改大部分工作代码的情况下,我删除了.net 4.5的ServiceRefernce1,并为.net 4添加了ServiceRefernce2,现在app.config将无法正常工作并继续提供
System.ServiceModel.ProtocolException
我的app.config for .net 4.5(正在工作)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="RSAWebServiceApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
<system.serviceModel>
<!--
<bindings>
<basicHttpBinding>
<binding name="VCSampleServiceSoap" />
</basicHttpBinding>
</bindings>
-->
<bindings>
<basicHttpBinding>
<binding name="defaultBasicHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://this.testservice.com/Sample/VCSampleService.asmx" binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding" contract="ServiceReference1.VCSampleServiceSoap" name="VCSampleServiceSoap"/>
</client>
</system.serviceModel>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
</configuration>
现在经过多次清理.net 4 app.config(非工作)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="IPSOSHarness2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="VCSampleServiceSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://this.testservice.com/Sample/VCSampleService.asmx"
binding="basicHttpBinding" bindingConfiguration="VCSampleServiceSoap"
contract="ServiceReference1.VCSampleServiceSoap" name="VCSampleServiceSoap" />
</client>
</system.serviceModel>
</configuration>
我试过了
<system.ServiceModel>
<services>
<service behaviorConfiguration="MyServiceBehavior"
name="VCSampleServiceSoap">
<endpoint address="https://this.testservice.com/Sample/VCSampleService.asmx"
binding="basicHttpBinding"
bindingConfiguration="defaultBasicHttpBinding"
contract="ServiceReference1.VCSampleServiceSoap"
name="VCSampleServiceSoap" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="defaultBasicHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.ServiceModel>
无论哪种方式我都无法在.net 4中运行,所以任何帮助修复这个或只是编译.net 4.5工作代码所以它在Windows Server 2003上没有.net 4.5框架工作?它需要是控制台应用程序,我知道有办法让它在asp.net中工作,但我无法从控制台更改。
答案 0 :(得分:1)
我已设法通过以下方式解决此问题:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="defaultBasicHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://this.testservice.com/Sample/VCSampleService.asmx" binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding" contract="ServiceReference1.VCSampleServiceSoap" name="VCSampleServiceSoap"/>
</client>
</system.serviceModel>