WCF Web 服务的错​​误请求 REST/SOAP

发布于 2025-01-11 15:16:40 字数 1709 浏览 0 评论 0原文

WCF 服务需要支持 SOAP 和 REST 格式。 它返回错误请求(400),下面是我的网络配置文件:

<system.serviceModel>
            <bindings>
                    <basicHttpBinding>
                        <binding name="BasicHttpBinding_ILoginSVC" allowCookies="true" maxBufferPoolSize="20000000" maxBufferSize="70000000" maxReceivedMessageSize="70000000">
                        </binding>
                    </basicHttpBinding>
                    <webHttpBinding>
                        <binding name="webHttpBindingILoginSVC" allowCookies="true" maxBufferSize="100000000" maxBufferPoolSize="100000000" maxReceivedMessageSize="100000000" crossDomainScriptAccessEnabled="true" />
                    </webHttpBinding>
                </bindings>
            <services>
                <service name="LoginSVC.LoginSVC">
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:59900/LoginSVC" />
                        </baseAddresses>
                    </host>
                    <endpoint address="" binding="basicHttpBinding" contract="LoginSVC.ILoginSVC">
                        <identity>
                            <dns value="localhost" />
                        </identity>
                    </endpoint>
                    <endpoint address="REST" binding="webHttpBinding" contract="LoginSVC.ILoginSVC" behaviorConfiguration="RESTEndPointBehaviour">
                    </endpoint>
                </service>
            </services>
        </system.serviceModel>

A WCF service needs to be capable to SOAP and REST format.
It returns Bad Request (400), below is my web config file:

<system.serviceModel>
            <bindings>
                    <basicHttpBinding>
                        <binding name="BasicHttpBinding_ILoginSVC" allowCookies="true" maxBufferPoolSize="20000000" maxBufferSize="70000000" maxReceivedMessageSize="70000000">
                        </binding>
                    </basicHttpBinding>
                    <webHttpBinding>
                        <binding name="webHttpBindingILoginSVC" allowCookies="true" maxBufferSize="100000000" maxBufferPoolSize="100000000" maxReceivedMessageSize="100000000" crossDomainScriptAccessEnabled="true" />
                    </webHttpBinding>
                </bindings>
            <services>
                <service name="LoginSVC.LoginSVC">
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:59900/LoginSVC" />
                        </baseAddresses>
                    </host>
                    <endpoint address="" binding="basicHttpBinding" contract="LoginSVC.ILoginSVC">
                        <identity>
                            <dns value="localhost" />
                        </identity>
                    </endpoint>
                    <endpoint address="REST" binding="webHttpBinding" contract="LoginSVC.ILoginSVC" behaviorConfiguration="RESTEndPointBehaviour">
                    </endpoint>
                </service>
            </services>
        </system.serviceModel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花落人离去 2025-01-18 15:16:40

在您的配置文件中,您尚未分配您创建的绑定配置,因此使用默认的BasicHttpBinding。您需要将您定义的绑定(BasicHttpBinding_ILoginSVC)显式分配给您的端点,如下所示:

<endpoint address="" bindingConfiguration="BasicHttpBinding_ILoginSVC" binding="basicHttpBinding" contract="LoginSVC.ILoginSVC" />

In your configuration file, you have not assigned the binding configuration you created, so use the default BasicHttpBinding. You need to explicitly assign the binding you defined (BasicHttpBinding_ILoginSVC) to your endpoint like this:

<endpoint address="" bindingConfiguration="BasicHttpBinding_ILoginSVC" binding="basicHttpBinding" contract="LoginSVC.ILoginSVC" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文