简体   繁体   中英

Calling https service from another one

I am trying to call a web service from a another WCF using custom C# code. However when I run my code, I get the following error:

在此输入图像描述

However it executed successfully when i ran it from Asp.net page.

Here is my service webconfig file

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5.2"/>
    <httpModules>
      <add name="ApplicationInsights" type="Microsoft.ApplicationInsights.Telemetry.Web.ApplicationInsightsModule"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
  </system.web>
  <connectionStrings>
    <add name="TesString" connectionString="Data Source=(localdb)\Kentico;Initial Catalog=MYDB;Integrated Security=True"
  providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BillUploadSoap1"/>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://testapp2.com/ssb/financial/billupload.asmx" binding="basicHttpBinding" bindingConfiguration="BillUploadSoap1"
    contract="SCTHSadad.BillUploadSoap" name="BillUploadSoap1"/>
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
  <remove name="ApplicationInsightsWebTracking"/>
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
    preCondition="managedHandler"/>
    </modules>
<!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
    <directoryBrowse enabled="true"/>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>

I think you are trying to consume an asmx web service as a WCF service in your client.

When you add the service reference, try as below -

在此输入图像描述

And delete all the config and binding info in your client app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM