不能从DLL调用WCF WebService [英] Cannot call WCF WebService from DLL

查看:101
本文介绍了不能从DLL调用WCF WebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我在CAD软件中运行的一个dll,调用一个WCF Webservice。
当我尝试建立我的代理时,我收到以下错误:


$ p

b $ b


找不到名为BasicHttpBinding_IAxaptaService的端点元素,并在ServiceModel客户端配置部分中签署AxaptaProxy.IAxaptaService。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到符合此名称的端点元素。


我已经搜索abit,我认为这个问题是由于我的DLL在另一个程序中运行。
有一些关于将EndPoint配置从应用程序复制到服务的文章,但是我并没有抓住我应该做的事情。



任何人都有一个想法,关于我如何使这项工作?



我的客户端创建的App.Config是这样的:

 <?xml version =1.0encoding =utf-8?> 
< configuration>
< system.serviceModel>
< bindings>
< basicHttpBinding>
< binding name =BasicHttpBinding_IAxaptaServicecloseTimeout =00:01:00
openTimeout =00:01:00receiveTimeout =00:10:00sendTimeout =00:01: 00
allowCookies =falsebypassProxyOnLocal =falsehostNameComparisonMode =StrongWildcard
maxBufferSize =65536maxBufferPoolSize =524288maxReceivedMessageSize =65536
messageEncoding =TexttextEncoding =utf-8transferMode =Buffered
useDefaultWebProxy =true>
< readerQuotas maxDepth =32maxStringContentLength =8192maxArrayLength =16384
maxBytesPerRead =4096maxNameTableCharCount =16384/>
< security mode =None>
< transport clientCredentialType =NoneproxyCredentialType =None
realm =/>
< message clientCredentialType =UserNamealgorithmSuite =Default/>
< / security>
< / binding>
< / basicHttpBinding>
< / bindings>
< client>
< endpoint address =http:// localhost:4726 / LM / AxaptaService.svc
binding =basicHttpBindingbindingConfiguration =BasicHttpBinding_IAxaptaService
contract =AxaptaProxy.IAxaptaService =BasicHttpBinding_IAxaptaService/>
< / client>
< /system.serviceModel>
< / configuration>

我已经尝试将它合并到我的web.config,在托管网络服务的网站上,因为这样:

 < system.serviceModel> 
< bindings>
< customBinding>
< binding name =GetStream.customBinding0>
< binaryMessageEncoding />
< httpTransport />
< / binding>
< / customBinding>
< basicHttpBinding>
< binding name =BasicHttpBinding_IAxaptaServicecloseTimeout =00:01:00
openTimeout =00:01:00receiveTimeout =00:10:00sendTimeout =00:01: 00
allowCookies =falsebypassProxyOnLocal =falsehostNameComparisonMode =StrongWildcard
maxBufferSize =65536maxBufferPoolSize =524288maxReceivedMessageSize =65536
messageEncoding =TexttextEncoding =utf-8transferMode =Buffered
useDefaultWebProxy =true>
< readerQuotas maxDepth =32maxStringContentLength =8192maxArrayLength =16384
maxBytesPerRead =4096maxNameTableCharCount =16384/>
< security mode =None>
< transport clientCredentialType =NoneproxyCredentialType =None
realm =/>
< message clientCredentialType =UserNamealgorithmSuite =Default/>
< / security>
< / binding>
< / basicHttpBinding>
< / bindings>
<行为>
< endpointBehaviors>
< behavior name =AutoCompletionAspNetAjaxBehavior>
< enableWebScript />
< / behavior>
< / endpointBehaviors>
< serviceBehaviors>
< behavior name =>
< serviceMetadata httpGetEnabled =true/>
< serviceDebug includeExceptionDetailInFaults =false/>
< / behavior>
< / serviceBehaviors>
< / behavior>
< serviceHostingEnvironment aspNetCompatibilityEnabled =truemultipleSiteBindingsEnabled =true/>
< services>
< service name =AutoCompletion>
< endpoint address =behaviorConfiguration =AutoCompletionAspNetAjaxBehaviorbinding =webHttpBindingcontract =AutoCompletion/>
< / service>
< service name =GetStream>
< endpoint address =binding =customBindingbindingConfiguration =GetStream.customBinding0contract =GetStream/>
< endpoint address =mexbinding =mexHttpBindingcontract =IMetadataExchange/>
< / service>
< / services>
< client>
< endpoint address =http:// localhost:4726 / LM / AxaptaService.svc
binding =basicHttpBindingbindingConfiguration =BasicHttpBinding_IAxaptaService
contract =AxaptaProxy.IAxaptaService =BasicHttpBinding_IAxaptaService/>
< / client>
< /system.serviceModel>

已经有几个其他的东西。我可以删除它们,如果这更容易。我已经离开他们,他们对它有一些影响。



所以我测试了这个服务,从一个独立的winform应用程序,它的工作正常。
可能是因为App.config?我的配置是否加载了.dll?

解决方案

我终于得到它的工作!



问题是,在.dll项目中,app.config没有加载。
为了解决这个问题,我在代码中创建了绑定,而不是通过这个线程中提到的app.config:
没有配置文件的WCF配置



谢谢你的帮助。梅林,没有你的帮助,我甚至不会这么远。


I'm trying to call a WCF Webservice, from a dll I have made, running inside our CAD Software. I cannot get it to work though.

When I try to establish my proxy, I get the following error:

Could not find endpoint element with name 'BasicHttpBinding_IAxaptaService' and contract 'AxaptaProxy.IAxaptaService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

I have searched around abit, and I assume the problem is due to my DLL running inside another program. There was some articles about copying EndPoint configuration from the app, to the service, but I didn't quite catch, what I was supposed to do.

Anyone have an idea, as to how I can make this work?

The App.Config, created by my client is this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IAxaptaService" 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="http://localhost:4726/LM/AxaptaService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAxaptaService"
                contract="AxaptaProxy.IAxaptaService" name="BasicHttpBinding_IAxaptaService" />
        </client>
    </system.serviceModel>
</configuration>

I have tried to merge this into my web.config, on the site that hosts the web-service, as this:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="GetStream.customBinding0">
          <binaryMessageEncoding/>
          <httpTransport/>
        </binding>
      </customBinding>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAxaptaService" 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>
    <behaviors>
      <endpointBehaviors>
        <behavior name="AutoCompletionAspNetAjaxBehavior">
          <enableWebScript/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <services>
      <service name="AutoCompletion">
        <endpoint address="" behaviorConfiguration="AutoCompletionAspNetAjaxBehavior" binding="webHttpBinding" contract="AutoCompletion"/>
      </service>
      <service name="GetStream">
        <endpoint address="" binding="customBinding" bindingConfiguration="GetStream.customBinding0" contract="GetStream"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <client>
      <endpoint address="http://localhost:4726/LM/AxaptaService.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAxaptaService"
          contract="AxaptaProxy.IAxaptaService" name="BasicHttpBinding_IAxaptaService" />
    </client>
  </system.serviceModel>

There are a couple of other stuff in there already. I can remove them, if that makes it easier. I've left them in, incase they have some influence on it.

So I tested the service, from a stand-alone winform application, and it works fine. Could it be because of the App.config? Does my config get loaded, for the .dll?

解决方案

I finally got it to work!

The problem was, that the app.config does not get loaded, in my .dll project. To fix this, I created the binding, in code, instead of through the app.config, as mentioned in this thread: WCF Configuration without a config file

Thank you for all the help though. Merlyn, without your help, I wouldn't even have gotten this far.

这篇关于不能从DLL调用WCF WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆