简体   繁体   English

Windows服务中托管的消耗Winform的WCF服务出现错误#405(不允许使用方法e)

[英]Winform consuming WCF service hosted in a Windows service got error #405 (method not allowed e)

WCF service is hosted in a Windows service. WCF服务托管在Windows服务中。 I get successful response from web browser, but I can't call it form a Winforms application. 我从Web浏览器获得了成功的响应,但是无法将其称为Winforms应用程序。 I always get an error #405. 我总是收到错误#405。 Any ideas? 有任何想法吗?

I have enabled "CORS" in my WCF service, I turned on all the required components from "Windows feature on and off ". 我已经在WCF服务中启用了“ CORS”,我从“打开和关闭Windows功能”中打开了所有必需的组件。

This is my client's app.config file 这是我客户的app.config文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <diagnostics>
            <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true"
                            logMessagesAtTransportLevel="true" />
            <endToEndTracing propagateActivity="true" activityTracing="true"
                             messageFlowTracing="true" />
        </diagnostics>
        <behaviors>
            <endpointBehaviors>
                <behavior name="AjaxBehavior">
                    <webHttp defaultOutgoingResponseFormat="Json"/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <client>
            <endpoint 
                address="http://localhost:8080/ "
                behaviorConfiguration="AjaxBehavior"
                binding="webHttpBinding"
                contract="IScaleService" />
        </client>
    </system.serviceModel>
</configuration>

This is my WCF service config file: 这是我的WCF服务配置文件:

<configuration>
    <appSettings>
        <add key="port" value="COM3"/>
    </appSettings>
    <system.serviceModel>
        <behaviors>
            <endpointBehaviors>
                <behavior name="AjaxBehavior">
                    <webHttp defaultOutgoingResponseFormat="Json"/>
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="WindowsScaleTypeBehaviors" >
                    <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/mex"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <webHttpBinding>
                <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
            </webHttpBinding>
        </bindings>
        <services>
            <service name="ScaleService.Scale"  
                     behaviorConfiguration="WindowsScaleTypeBehaviors">
                <endpoint 
                    address="" 
                    behaviorConfiguration="AjaxBehavior" 
                    binding="webHttpBinding"
                    bindingConfiguration="webHttpBindingWithJsonP"
                    contract="ScaleService.IScaleService" />
                <endpoint 
                    address="mex"
                    binding="mexHttpBinding"
                    contract="IMetadataExchange"/>
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8080/" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>
</configuration>

Finally, I found what's wrong with my app. 最后,我发现我的应用程序出了什么问题。 The auto generated proxy class did not add webget attribute to the operation. 自动生成的代理类未将webget属性添加到操作。

[System.ServiceModel.Web.WebGet]
 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IScaleService/Get_Available_Ports", ReplyAction="http://tempuri.org/IScaleService/Get_Available_PortsResponse")]
 ScaleService.Lib.Ports[] Get_Available_Ports();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自托管WCF服务引发错误消息“ 405方法不允许” - Self Hosted WCF Service throws Error Message “405 Method not allowed” 从另一个WCF服务(自行托管)使用一个WCF服务(托管在Windows Service上)时出错 - Error while consuming one WCF Service (hosted on Windows Service) from another WCF Service (self hosted) 方法不允许(http错误405),wcf,休息服务,post方法 - Method not allowed (http error 405) , wcf , rest service , post method WCF服务405方法不允许例外 - WCF Service 405 Method Not Allowed Exception 带有WCF服务的Angular JS中的405(不允许使用方法) - 405 (Method Not Allowed) in Angular JS With WCF Service Web服务Windows Phone 7(405)方法不允许 - Web Service Windows Phone 7 (405) Method Not Allowed 使用从外部解决方案托管在Windows服务中的WCF服务 - Consuming a WCF Service that is hosted in a Windows Service from outside solution 消耗Windows Service中托管的WCF服务时出现HTTP获取错误 - Getting HTTP Get Error while Consuming WCF Service hosted in Windows Service REST 服务错误 405:方法不允许 - REST Service Error 405: Method not allowed 自我托管的Web服务中不允许使用405-方法 - Getting 405-Method not allowed in self hosted web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM