wcf 服务不允许 POST

2024-04-13

一般来说,我对 Web 服务还很陌生,并且(我认为)陷入了配置 IIS 和 Web 服务本身的困境。

我在 MVS 2010 中创建了一个 wcf Web 服务,并将其托管在 Windows 7 上的 IIS7.5 上。 我使用soapUI 4.5.0 来发布一条消息,该消息是根据我创建的Web 服务合约所用的相同wsdl 描述生成的。问题是我得到 405 是因为 web 服务或 web 服务器似乎不支持 http POST。

尽管我认为我得到的错误足以解决我的问题,但我对 IIS 和 Web 服务缺乏了解,使得我找不到正确的解决方案。

下面是我能想到的尽可能多的信息。希望它有任何帮助,并且有人可以指导我正确的方向。

在IIS中进行的配置:

授权规则:允许,所有用户

  • 目录浏览:启用
  • 处理程序映射:功能权限:读取、脚本和执行
  • 处理程序映射:添加了 *.wsdl -> ProtocolSupportModule -> GET、HEAD、OPTIONS、TRACE、POST
  • 应用程序池:使用身份 NetworkService 添加条目 .net固件4.0

这是发送的消息:

生的: 发布 http: x.x.x.x:21378/HTTP/1.1 接受编码:gzip、deflate 内容类型:application/soap+xml;charset=UTF-8;action="/BootNotification"

XML:

<soap:Envelope xmlns:soap="org/2003/05/soap-envelope" xmlns:ns="urn://Ocpp/Cs/2012/02/">
   <soap:Header/>
   <soap:Body>
      <ns:bootNotificationResponse>
         <ns:status>Accepted</ns:status>
         <ns:currentTime>${now}</ns:currentTime>
         <ns:heartbeatInterval>900</ns:heartbeatInterval>
      </ns:bootNotificationResponse>
   </soap:Body>
</soap:Envelope>

这是返回的结果:

我截断了它以限制这篇文章的大小。

生的: HTTP/1.1 405 方法不允许 缓存控制:私有 允许:获取、头部、选项、跟踪 内容类型:text/html;字符集=utf-8 服务器:微软-IIS/7.5 X-Powered-By: ASP.NET 日期:2012 年 6 月 7 日星期四 07:58:09 GMT 内容长度:5611

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns=".org/1999/xhtml"> 
<head> 
<title>IIS 7.5 Detailed Error - 405.0 - Method Not Allowed</title> 
<style type="text/css"> 

...
...
...

<div class="content-container"> 
 <fieldset><legend>Most likely causes:</legend> 
  <ul>  <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li>   <li>A request was sent to the server that contained an invalid HTTP verb.</li>  <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li>    <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Things you can try:</legend> 
  <ul>  <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li>    <li>Check the IIS log file to see which verb is not allowed for the request.</li>   <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href=".com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
 </fieldset> 
</div> 


<div class="content-container"> 
 <fieldset><legend>Links and More Information</legend> 
  This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request. 
  <p><a href="amp;IIS70Error=405,0,0x80070001,7601">View more information &raquo;</a></p> 

 </fieldset> 
</div> 
</div> 
</body> 
</html> 

XML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ".org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns=".org/1999/xhtml"> 
<head> 
<title>IIS 7.5 Detailed Error - 405.0 - Method Not Allowed</title> 
<style type="text/css"> 

...

</head> 
<body> 
<div id="header"><h1>Server Error in Application "SHENZIWEBSERVICEDEPLOYED"</h1></div> 
<div id="server_version"><p>Internet Information Services 7.5</p></div> 
<div id="content"> 
<div class="content-container"> 
 <fieldset><legend>Error Summary</legend> 
  <h2>HTTP Error 405.0 - Method Not Allowed</h2> 
  <h3>The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.</h3> 
 </fieldset> 
</div> 
<div class="content-container"> 

...

</div> 
<div class="content-container"> 
 <fieldset><legend>Most likely causes:</legend> 
  <ul>  <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li>   <li>A request was sent to the server that contained an invalid HTTP verb.</li>  <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li>    <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Things you can try:</legend> 
  <ul>  <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li>    <li>Check the IIS log file to see which verb is not allowed for the request.</li>   <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href=".com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
 </fieldset> 
</div> 


<div class="content-container"> 
 <fieldset><legend>Links and More Information</legend> 
  This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request. 
  <p><a href=".com/fwlink/?LinkID=62293&amp;IIS70Error=405,0,0x80070001,7601">View more information &raquo;</a></p> 

 </fieldset> 
</div> 
</div> 
</body> 
</html> 

这是生成的服务合同的一部分(wsdl /语言:CS /serverInterface

// CODEGEN: The optional WSDL extension element 'PolicyReference' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
[ServiceContract(Name = "CentralSystemServiceSoap", Namespace = "urn://Ocpp/Cs/2010/08/")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Web.Services.WebServiceBindingAttribute(Name="CentralSystemServiceSoap", Namespace="urn://Ocpp/Cs/2010/08/")]
public interface ICentralSystemServiceSoap {
    /// <remarks/>
    [OperationContract]
    [System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
    [System.Web.Services.WebMethodAttribute()]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("/BootNotification", RequestElementName = "bootNotificationRequest", RequestNamespace = "urn://Ocpp/Cs/2010/08/", ResponseElementName = "bootNotificationResponse", ResponseNamespace = "urn://Ocpp/Cs/2010/08/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    [return: System.Xml.Serialization.XmlElementAttribute("status")]
    RegistrationStatus BootNotification(string chargePointVendor, string chargePointModel, string chargePointSerialNumber, string chargeBoxSerialNumber, string firmwareVersion, string iccid, string imsi, string meterType, string meterSerialNumber, out System.DateTime currentTime, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool currentTimeSpecified, out int heartbeatInterval, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool heartbeatIntervalSpecified);

我不明白你的服务是如何构建的以及你在那里做了什么,但根据我的经验,这是创建支持 POST 请求的 wcf RESTful 服务的简单方法:

http://www.codeproject.com/Articles/201901/CREATE-RESTful-WCF-Service-API-Using-POST-Step-By http://www.codeproject.com/Articles/201901/CREATE-RESTful-WCF-Service-API-Using-POST-Step-By

根据评论更新:

尝试使用它:

[OperationContract]
[WebInvoke(Method = "POST")]
[System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("/BootNotification", RequestElementName = "bootNotificationRequest", RequestNamespace = "urn://Ocpp/Cs/2010/08/", ResponseElementName = "bootNotificationResponse", ResponseNamespace = "urn://Ocpp/Cs/2010/08/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("status")]
RegistrationStatus BootNotification(string chargePointVendor, string chargePointModel, string chargePointSerialNumber, string chargeBoxSerialNumber, string firmwareVersion, string iccid, string imsi, string meterType, string meterSerialNumber, out System.DateTime currentTime, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool currentTimeSpecified, out int heartbeatInterval, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool heartbeatIntervalSpecified);

UPDATE

尝试这样做:

在 IIS 7.5 上 -> 您的网站 -> 处理程序映射

选择面板右侧的“添加模块映射”选项

在“请求路径”字段中输入 *.wsdl

在“模块”字段中输入“ProtocolSupportModule”

单击“请求限制”并转到动词选项卡

输入 POST 动词

保存更改

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

wcf 服务不允许 POST 的相关文章

  • HTTP 状态 400 验证与验证

    虽然RFC 7231 https www rfc editor org rfc rfc7231目的是为了清晰起见 但它显然给状态代码 400 带来了歧义 请注意这一点所以答案和评论 https stackoverflow com a 329
  • 为什么我使用的 KnownType 属性是错误的?

    我正在尝试反序列化来自 google api 的 json 响应 所以我想我应该定义几个类来帮助它 DataContract public class DetectionResult ResponseData DataMember Name
  • 如何更改Spring-WS的“SOAP-ENV”默认前缀

    我使用 Spring WS 创建了一个 Web 服务 为了保持与旧系统的兼容性 我需要将命名空间前缀从SOAP ENV to soap 我知道SOAP ENV and soap只是命名空间前缀 只要它们引用正确的命名空间 http sche
  • 无法引用 AppFabric 上托管的 WCF Web 服务的 WSDL

    我开发了一个 WCF 服务 并且在 Visual Studio 2010 中 我可以毫无问题地导入 WSDL 将其部署到 AppFabric 后 我获得了 WSDL 但由于某种原因无法找到 WSDL 内部引用的几个架构文件 不知道是配置问题
  • 如何使用包含点/句点的 MVC5 基于属性的路由?

    我基本上有一个开箱即用的 MVC 5 2 应用程序 启用了基于属性的路由 调用routes MapMvcAttributeRoutes 从提供的RouteConfig RegisterRoutes RouteCollection route
  • System.Net.WebException:请求已中止:请求已取消

    我有一个 WCF 服务 在负载条件下一直给我这个错误 并且我似乎无法重新创建该错误 我们已经尝试寻找解决方法大约一周了 但没有这样的运气 我看到的错误有两个部分 System ServiceModel CommunicationExcept
  • WCF 服务基地址 Http 和 netTcp

    我的 WCF 服务配置文件中定义了两个基址
  • WCF WebGetAttribute 与 WebInvokeAttribute

    WebGetAttribute 只是 Method GET 的 WebInvokeAttribute 的语法糖吗 或者有根本的区别吗 您立即观察到 WebGet 和 WebInvoke 非常相似 这与事实相差不远 正如您已经说过的 WebG
  • 为什么 Asp.Net Core 2.1 WebApi 返回 500.19 错误?

    我有一个小型 webapi 服务 它可以在 Visual Studio 下工作 但不能在 IIS 下工作 我做了下一步 新应用程序已添加到 IIS 控制台中的默认网站 应用程序通过文件系统从 VS 发布到应用程序文件夹中 选择了依赖框架和可
  • 无法在 web.config 中为 WCF Web 服务设置服务名称属性

    我编写了一个运行良好的 WCF Web 服务 然后我从另一个应用程序复制了该 Web 服务的内容 并创建了一个新的 WCF 文件 该文件在 web config 中创建了一个新文件 但名称属性显示找不到命名空间 以下是我的 WCF 前几行的
  • 在获得响应之前发出多个请求

    当并行发送多个请求时 在获得响应之前 我无法理解 HTTP 的工作原理 有两种情况 1 With Connection Keep Alive 根据HTTP规范 http www w3 org Protocols rfc2616 rfc261
  • 我应该使用哪种协议来传输音频(非直播)? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • IIS:添加功能

    我需要使用 IIS 7 0 中的 IP 地址和域限制功能编辑 IP 规则 但在我的 Windows 7 计算机上 我的 IIS 中不存在此功能 有谁知道如何向 IIS 添加此功能 我无法在任何地方找到下载 或 IIS 中用于添加功能的部分
  • AngularJS $http 错误时 http 状态错误

    我正在尝试使用 AngularJS 的 http 服务构建 JSONP 请求 并且在出现错误时 我收到错误的 http 状态代码 404 而不是 500 并且页面正文也丢失了 所以这是场景 我调用的 URL 返回 500 内部服务器错误 并
  • 允许在 Visual Studio Express 2013 for Web 中加载 JSON 文件

    我遇到的问题是 Visual Studio Express 2013 for Web 中的 IIS 不允许加载 json 文件 当尝试加载 json 文件时 我收到 403 Forbidden 和帮助页面如何配置 IIS 允许加载 JSON
  • 在 WCF 服务上的 AJAX 发出 REST 请求期间启用 CORS 中的 OPTIONS 方法

    我花了7个小时绞尽脑汁想弄清楚这个问题 我在整个网络上进行了搜索 但没有运气 我有一个 Angular 应用程序正在向 WCF 命令行托管服务应用程序发出请求 我设法通过使用这两个类来实现 CORS public class CustomH
  • 脚本和链接标签的简写 http:// 为 // ?有人以前看过/用过这个吗?

    问题如下 如果您使用 addthis 共享按钮 查看任何网站 一旦您浮动在 addthis 按钮上 并且加载了所有必需的资源 请使用 firebug 或 chrome 检查器查看文档的正文 不是源代码 而是屏幕上的实际文档 对象检查器 你会
  • 通过 facebook api 在 facebook feed 中发布 swf

    我正在使用下面的数组 feeddata array type gt flash method gt stream publish display gt iframe link gt https developers facebook com
  • Http Auth 不适用于 PHP

    我使用 Laravel Lumen Shield 扩展进行 Http 身份验证 但是在我的本地计算机上一切都很完美 我只在我们的服务器上遇到了问题 问题是在我提交正确的登录数据后 登录屏幕再次出现 我尝试了不同的登录数据 不同的浏览器 登录
  • 摆脱浏览器控制台中的 401(未经授权)ajax 错误

    我正在使用 javascript 通过 api 调用jQuery ajax http api jquery com jQuery ajax 称呼 如果用户未经过身份验证 API 会响应 401 并且我只想针对此调用忽略此错误 我已经尝试了

随机推荐

  • 使用 Sinon 测试 D3 中的鼠标悬停事件

    我在试图通过测试时遇到了麻烦 我希望能够使用间谍来检查鼠标悬停事件是否被正确调用 目前 我收到以下错误 错误 预计已被调用至少一次但从未被调用 我的部分困惑与 d3 和 jQuery 选择器之间的差异有关 我非常乐意使用后者 但我不确定如何
  • 正则表达式限制字符串大小

    如何限制此正则表达式的字符串大小 a z a z0 9 a z0 9 我只需要添加量词 3 16 撒上一些积极的前瞻 http www regular expressions info lookaround html通过添加来测试字符串的总
  • 令人困惑的苹果应用内购买产品

    我正在创建一个笔记应用程序 例如 iPad 版 Evernote 我决定提供一些应用内购买计划有两个原因 解锁应用程序中的更多功能 应在指定时间段后自动更新 现在我很困惑为此选择哪种类型的应用内购买 我对感兴趣自动续订订阅 访问指南后her
  • SqlCommand.Cancel() 会导致性能提升吗?

    我已经看到它出现在代码中的多个位置 从来没有解释 只是在其上方有一个神秘的注释 包含声明和执行以了解上下文 这只是运行 SqlCommand 的标准过程 SqlCommand cmd new SqlCommand cmd ExecuteRe
  • Swift where 条件检查属性是否已实现

    我刚刚找到了另一种在 Swift 中充分利用协议和协议扩展的方法 即扩展可选协议来添加函数 以便我可以提供默认值 我在这里写了一篇关于此的博客文章 https janthielemann de random stuff providing
  • 获取 DbContext 中当前登录的用户

    出于审计目的 我尝试在 DbContext 中获取当前登录的用户 不过我对此有一些问题 需要考虑以下几点 在 Blazor Server 中我们必须使用 AddDbContextFactory IHttpContextAccessor 在部
  • 如何使用 PHP 从文档中获取数字签名

    我对数字签名这个东西很陌生 我想做的是检查文档是否经过数字签名 如果已签名 则验证签名 我已经搜索了很多 我发现了一些有关验证签名 使用 openssl 的有用主题 但我找不到有关以下内容的任何内容 文档是否已签名 我还在stackover
  • 可以或应该同时运行的 Promise 数量是否有限制?

    令人惊讶的是 谷歌无法返回这个问题的结果 我想知道在排队并等待下一个完成之前可以或应该并行运行多少个承诺 我想这可能取决于用户的互联网 但我认为值得一问 如果它基于用户的 ISP 连接类型 是否有办法在启动队列之前测试发送的理想承诺数量 另
  • 增量数据库字段

    假设我在网站上有一篇文章 我想跟踪该文章的浏览量 在 Articles 表中 有 PK ID int Name nvarchar 50 和 ViewCount int 每次查看页面时 我都会增加 ViewCount 字段 我担心更新字段时发
  • 以编程方式获取 TFS 责任(注释)数据

    我正在尝试为 Team Foundation Server 2010 实现一个插件 该插件将创建有关团队项目中的用户的报告 从概念上讲 为了正确实现此插件 我需要访问与在 Visual Studio 中使用 注释 功能时获得的相同数据 我需
  • Kivy 和 android 共享首选项

    我正在寻找一种从 Kivy 框架在 Android 设备上持久存储设置的方法 我发现 Kivy 文档总体信息丰富 但在这个特定领域含糊不清 它提到了三种方法 抱歉 没有足够的声誉来提供可点击的链接 相对路径kivy org假如 如果有人可以
  • 我们可以同时使用“export default”和“module.exports”吗?

    如何使用export default and module exports在同一个文件中 出口 export default function module exports A B C 如何导入它们 很确定这是不可能的 默认导出基本上与您分
  • 如何在 TypeScript 中实现睡眠功能?

    我正在使用 TypeScript 在 Angular 2 中开发一个网站 我想知道是否有办法实现thread sleep ms 功能 我的用例是在几秒钟后提交表单后重定向用户 这在 JavaScript 中非常简单 但我不确定如何在 Typ
  • 如何在 WebGL 中创建合适的圆角矩形?

    我试图实现答案这个问题 https stackoverflow com questions 43970170 bordered rounded rectangle in glsl但似乎有点问题 如果您打开他们的 ShaderToys 并尝试
  • org.dbunit.dataset.NoSuchTableException,但表存在

    H2 1 4 191 数据库单元 2 5 1 如何解决这个问题 3种情况的代码和结果 org dbunit dataset NoSuchTableException category org dbunit dataset NoSuchTab
  • 为什么我的 wss://(基于 SSL/TLS 的 WebSockets)连接立即断开而不给出任何错误?

    将此发布给遇到同样问题的其他人 我当时正在开发一个浏览器客户端 它使用 stanza io 连接到 XMPP 服务器 在我的例子中是 Prosody 我默认使用 wss 连接 在开发过程中的某个时刻 我的客户端根本无法连接 它会立即无提示地
  • iphone 4.0 以编程方式发送短信

    我正在开发一个简单的应用程序 在其中我需要以编程方式向我的朋友发送短信 所以编写下面的代码来发送短信 MFMessageComposeViewController picker MFMessageComposeViewController
  • 比较 2 个对象数组并删除重复项

    我在 JavaScript 中有 2 个对象数组 想要比较和合并内容并按 id 对结果进行排序 具体来说 生成的排序数组应包含第一个数组中的所有对象 以及第二个数组中具有不在第一个数组中的 id 的所有对象 以下代码似乎有效 减去排序 但必
  • 派生类的初始值设定项列表

    我想要一个派生类 它有一个默认构造函数来初始化继承成员 为什么我可以这样做 class base protected int data class derived public base public derived note data 4
  • wcf 服务不允许 POST

    一般来说 我对 Web 服务还很陌生 并且 我认为 陷入了配置 IIS 和 Web 服务本身的困境 我在 MVS 2010 中创建了一个 wcf Web 服务 并将其托管在 Windows 7 上的 IIS7 5 上 我使用soapUI 4