【问题标题】:Calling a webservice from a C# dll from within CLASSIC ASP从 CLASSIC ASP 中的 C# dll 调用 Web 服务
【发布时间】:2013-06-03 21:32:32
【问题描述】:

我是一名 Windows 开发人员,对 Web 应用程序和 ASP 知之甚少。我正在尝试为某人创建一个从 CLASSIC ASP 应用程序调用的 C# dll(正在调用 Web 服务)。

这一切都始于一个成功加载 WSDL 并调用该 Web 服务的 WinForms 测试应用程序。现在的要求是获取测试应用程序的功能,将其移动到 dll 并从 ASP 应用程序调用该 dll。我天真地把 appconfig 文件留在那里,当那个 dll 被调用时,他得到了这个众所周知的错误:

找不到引用合约 Service1.MyService 的默认端点元素 ServiceModel 客户端配置部分。这可能是因为没有找到配置文件 对于您的应用程序,或者因为在 客户端元素。

我知道经典的 asp 没有配置文件 - 我阅读了很多关于它的帖子,大多数相关的帖子都提到使用 BasicHTTPBinding 并即时提供端点地址。我怎么做?有什么例子吗?

我看到了这个答案:

我需要做的就是创建一个 BasicHTTPBinding 并即时提供一个端点地址。然后使用创建的绑定和端点地址创建一个新的 Web 服务实例。

但我不知道该怎么做。

这是适用于 winforms 应用的 appconfig:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMyService">
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" proxyCredentialType="None"
                        realm="" />
                </security>
            </binding>
            <binding name="BasicHttpBinding_ICustomerService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://MyService.svc"
            behaviorConfiguration="custom" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IMyService" contract="MyService.IMyService"
            name="BasicHttpBinding_IMyService" />
    </client>


  <behaviors>
    <endpointBehaviors>
      <behavior name="custom">
        <customInspector />
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <extensions>
    <behaviorExtensions>
      <add name="customInspector" type="CustomBehaviors.CustomBehaviorExtensionElement, CompeteDataServiceTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    </behaviorExtensions>
  </extensions>


</system.serviceModel>

【问题讨论】:

    标签: wcf dll asp-classic wsdl


    【解决方案1】:

    您需要通过代码配置服务,因为在这种情况下没有配置文件。见Configuring WCF Services in Code

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-25
      相关资源
      最近更新 更多