WCF终端和放大器;绑定配置问题 [英] WCF Endpoints & Binding Configuration Issues

查看:213
本文介绍了WCF终端和放大器;绑定配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个很奇怪的问题在这里的乡亲。为了简单起见,我创建了一个项目来测试一个较大的应用程序框架之外这个问题的唯一目的,仍然遇到了什么或者是一个在WCF Visual Studio 2010中或某事涉及到我的WCF新手技能中的错误:)

I am running into a very strange issue here folks. For simplicity I created a project for the sole purpose of testing the issue outside the framework of a larger application and still encountered what is either a bug in WCF within Visual Studio 2010 or something related to my WCF newbie skill set : )

下面是问题:

我有一个WCF端点我创建一个名为SimpleMethod的MVC3项目内部运行。该方法在应用程序的根目录的.svc文件的内部运行,它返回一个布尔值。

I have a WCF endpoint I created running inside of an MVC3 project called "SimpleMethod". The method runs inside of a .svc file on the root of the application and it returns a bool.

使用WCF服务配置编辑器我曾与一个名为LargeImageBinding一起加入终端到我的web.config。

Using the "WCF Service Configuration Editor" I have added the endpoint to my Web.Config along with a called "LargeImageBinding".

下面是该服务:

    [OperationContract]
    public bool SimpleMethod()
    {
        return true;
    }

和由配置工具生成的Web.Config中:

And the Web.Config generated by the Config Tool:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="LargeImageBinding" closeTimeout="00:10:00" />
  </wsHttpBinding>
</bindings>
<services>
  <service name="WCFEndpoints.ServiceTestOne">
    <endpoint address="/ServiceTestOne.svc" binding="wsHttpBinding"
      bindingConfiguration="LargeImageBinding" contract="WCFEndpoints.IServiceTestOne" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

该服务使罚款,你可以看到终点,当你浏览到:的http://本地主机:57364 / ServiceTestOne .SVC - 现在,当我创建一个单独的项目来使用服务时出现问题。我添加一个服务引用上述项目的运行实例,它指向:的http://本地主机:57364 / ServiceTestOne .SVC

The service renders fine and you can see the endpoint when you navigate to: http://localhost:57364/ServiceTestOne.svc - Now the issue occurs when I create a separate project to consume the service. I add a service reference to a running instance of the above project, point it to: http://localhost:57364/ServiceTestOne.svc

下面是怪异的一部分。该服务自动生成得很好,但在Web.config生成的端点看起来是这样的:

Here is the weird part. The service automatically generates just fine but In the Web.Config the endpoint that is generated looks like this:

<client>
  <endpoint address="http://localhost:57364/ServiceTestOne.svc/ServiceTestOne.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceTestOne"
    contract="ServiceTestOne.IServiceTestOne" name="WSHttpBinding_IServiceTestOne">

正如你可以看到它列出了地址的ServiceTestOne.svc部分的两倍!

As you can see it lists the "ServiceTestOne.svc" portion of the address twice!

当我做出的服务我得到以下错误的呼叫:

When I make a call to the the service I get the following error:

远程服务器返回错误:(404)未找到

The remote server returned an error: (404) Not Found.

我试着在上面的配置端点地址的末端卸下额外的/ServiceTestOne.svc,我也得到同样的确切的错误。

I tried removing the extra "/ServiceTestOne.svc" at the end of the endpoint address in the above config, and I get the same exact error.

现在是什么工作,如果我回去的WCF应用程序并删除web.config中的自定义端点和绑定引用(一切都在服务和绑定标签),然后返回给消费者应用程序,更新参考服务,并拨打电话到SimpleMethod().... BOOM就像一个魅力,我得到一个布尔值设置为true。

Now what DOES work is if I go back to the WCF application and remove the custom endpoint and binding references in the Web.Config (everything in the "services" and "bindings" tags) then go back to the consumer application, update the reference to the service and make the call to SimpleMethod()....BOOM works like a charm and I get back a bool set to true.

问题是,我需要以允许访问该服务的默认设置外进行自定义绑定配置,并从我可以告诉,任何试图创建自定义绑定,使端点似乎一切正常,但当失败的一个实际方法调用。

The thing is, I need to make custom binding configurations in order to allow for access to the service outside of the defaults, and from what I can tell, any attempt to create custom bindings makes the endpoints seem to run fine, but fail when an actual method call is made.

任何人都可以看到我是如何把这个共同的缺陷?谢谢你的时间 - 我一直在圈子里这个运行了大约一个星期

Can anyone see any flaw in how I am putting this together? Thank you for your time - I have been running in circles with this for about a week!

推荐答案

当承载在IIS中的WCF服务,使用以下格式形成服务的基地址:{}协议:// {HOST}:{端口} / {的applicationName} / {svcFileName}。这是你可以浏览,以获得WCF帮助页面和/或元数据(在默认配置)的地址。

When hosting a WCF service in IIS, the base address of the service is formed using the following format: {protocol}://{host}:{port}/{applicationName}/{svcFileName}. This is the address you can browse to get the WCF help page and/or the metadata (on a default configuration).

要形成端点(一个客户端需要使用)的实际地址,使用以下格式:{serviceBaseAddress} / {}的EndpointAddress

To form the actual address of the endpoint (the one your client needs to use), the following format is used: {serviceBaseAddress}/{endpointAddress}

以上比较的格式和您提供的示例配置说明了为什么你在你的客户端地址获得ServiceTestOne.svc两次。

Comparing the format above and the sample configuration you provided explains why you're getting ServiceTestOne.svc twice in your client address.

如果你希望你的服务的地址是的http://本地主机:57364 / ServiceTestOne.svc ,我建议你留下地址,你的端点配置属性为空:

If you want the address of your service to be http://localhost:57364/ServiceTestOne.svc, I'd recommend leaving the address attribute empty in your endpoint configuration:

<endpoint address="" ... />

这篇关于WCF终端和放大器;绑定配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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