asp.net – SOAP 1.2在SOAP 1.1工作时产生错误请求
我创建了一个ASP.NET Web服务(asmx),允许第三方软件连接到我的解决方案.
当从服务器所驻留的服务器调用时,使用SOAP 1.1或ASP.NET的调用表调用web服务时效果很好. 那么问题是什么,连接方只支持SOAP 1.2,当使用SOAP 1.2调用web服务时,它返回400 Bad请求. 我在web.config中启用了SOAP 1.2: <configuration> <system.web> <webServices> <soapExtensionTypes> <add type="Microsoft.Web.Services2.WebServicesExtension,Microsoft.Web.Services2,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" priority="1" group="0" /> </soapExtensionTypes> <protocols> <add name="HttpSoap12" /> <add name="HttpGet" /> <add name="HttpPost" /> </protocols> </webServices> </system.web> </configuration> 我将扩展用于另一部分,我试图通过特定于位置的配置禁用它,但是没有产生任何结果. 我启用了跟踪: <system.diagnostics> <trace autoflush="true" /> <sources> <source name="System.Web.Services.Asmx"> <listeners> <add name="AsmxTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:Trace.log" traceOutputOptions="LogicalOperationStack,DateTime,Timestamp,ProcessId,ThreadId" /> </listeners> </source> </sources> <switches> <add name="System.Web.Services.Asmx" value="Verbose" /> </switches> </system.diagnostics> 使用Chrome Advanced Rest Client我发送以下请求: <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <authenticateUser xmlns="http://services.kvh.nl/foo"> <username>kvh</username> <password></password> </authenticateUser> </soap12:Body> </soap12:Envelope> 这导致400错误请求和跟踪日志中的以下条目: System.Web.Services.Asmx Information: 0 : Calling IHttpHandlerFactory.GetHandler Caller: System.Web.Services.Protocols.WebServiceHandlerFactory#6565889::GetHandler() Request Host Address: 10.1.1.8 Request Host Name: lb03.kvh.local Request Url: [POST] http://services.kvh.nl/Services/MyWebservice.asmx ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.1166408Z Timestamp=9623920014337 System.Web.Services.Asmx Information: 0 : Calling XmlSerializer [Create XmlSerializer] Method: System.Xml.Serialization.XmlSerializer#1912278872::FromMappings(System.Xml.Serialization.XmlMapping[]#40573663=[24],System.Security.Policy.Evidence#667347099=..) Caller: System.Web.Services.Protocols.SoapServerType#31148249::.ctor(WWW.Services.MyWebservice#477438864=WWW.Services.MyWebservice,System.Web.Services.Configuration.WebServiceProtocols#63=HttpGet,HttpPost,Documentation,HttpPostLocalhost,AnyHttpSoap) ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.1478409Z Timestamp=9623920106472 System.Web.Services.Asmx Information: 0 : Return from XmlSerializer [Create XmlSerializer] Caller: System.Web.Services.Protocols.SoapServerType#31148249::.ctor(WWW.Services.MyWebservice#477438864=WWW.Services.MyWebservice,AnyHttpSoap) ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.3038412Z Timestamp=9623920433863 System.Web.Services.Asmx Information: 0 : Calling SoapExtension Method: Microsoft.Web.Services2.WebServicesExtension#3391963::ProcessMessage(System.Web.Services.Protocols.SoapMessageStage#4=BeforeDeserialize) Caller: System.Web.Services.Protocols.SoapServerMessage#31258077::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#34069029=[1],System.Boolean#0=False) ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.3038412Z Timestamp=9623920435703 System.Web.Services.Asmx Information: 0 : Return from SoapExtension Caller: System.Web.Services.Protocols.SoapServerMessage#31258077::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#34069029=[1],System.Boolean#0=False) ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.3506412Z Timestamp=9623920542168 System.Web.Services.Asmx Warning: 0 : Exception caught in System.Web.Services.Protocols.SoapServerProtocolFactory#48477748::Create. System.Xml.XmlException: Root element is missing. ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.3506412Z Timestamp=9623920545216 System.Web.Services.Asmx Warning: 0 : Exception Details: System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read() at System.Xml.XmlReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type,HttpContext context,HttpRequest request,HttpResponse response) at System.Web.Servic... ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.3506412Z Timestamp=9623920548659 System.Web.Services.Asmx Error: 0 : Exception thrown in System.Web.Services.Protocols.WebServiceHandlerFactory#6565889::CoreGetHandler(). System.InvalidOperationException: Failed to handle request. ProcessId=11272 LogicalOperationStack= ThreadId=6 DateTime=2014-05-22T13:28:45.3506412Z Timestamp=9623920549597 我已经用谷歌搜索了近乎精神错乱,但不幸的是我无法找到解决方案. 很感谢任何形式的帮助. 编辑: 不幸的是,rAhuID的建议删除了SOAP 1.1支持,但这并没有解决问题.我继续尝试了一些选项,例如清除所有协议,只添加HttpSoap12和文档,这看起来更糟糕.然后我删除了所有不需要的协议. XmlException从日志中消失,但我仍然收到400 Bad请求:( 我已经从本地计算机(使用hosts文件,因此我可以使用正确的主机名)进行测试,以排除代理服务器的问题. Currrent web.config: <protocols> <!-- <clear /> <add name="Documentation" /> <add name="HttpSoap12" /> --> <remove name="HttpGet" /> <remove name="HttpPost" /> <remove name="HttpPostLocalhost" /> <remove name="HttpSoap" /> </protocols> 诊断: System.Web.Services.Asmx Information: 0 : Calling IHttpHandlerFactory.GetHandler Caller: System.Web.Services.Protocols.WebServiceHandlerFactory#31931339::GetHandler() Request Host Address: 127.0.0.1 Request Host Name: web01.kvh.nl Request Url: [POST] http://services.kvh.nl/services/MyWebservice.asmx ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:39.7977582Z Timestamp=9802327858068 System.Web.Services.Asmx Information: 0 : Calling XmlSerializer [Create XmlSerializer] Method: System.Xml.Serialization.XmlSerializer#1912278872::FromMappings(System.Xml.Serialization.XmlMapping[]#53221370=[24],System.Security.Policy.Evidence#656725186=..) Caller: System.Web.Services.Protocols.SoapServerType#63548859::.ctor(WWW.Services.MyWebservice#445910576=WWW.Services.MyWebservice,System.Web.Services.Configuration.WebServiceProtocols#40=Documentation,HttpSoap12) ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:39.8445582Z Timestamp=9802327942578 System.Web.Services.Asmx Information: 0 : Return from XmlSerializer [Create XmlSerializer] Caller: System.Web.Services.Protocols.SoapServerType#63548859::.ctor(WWW.Services.MyWebservice#445910576=WWW.Services.MyWebservice,HttpSoap12) ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:39.9849585Z Timestamp=9802328272841 System.Web.Services.Asmx Information: 0 : Calling SoapExtension Method: Microsoft.Web.Services2.WebServicesExtension#59584177::ProcessMessage(System.Web.Services.Protocols.SoapMessageStage#4=BeforeDeserialize) Caller: System.Web.Services.Protocols.SoapServerMessage#64042303::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#63331368=[1],System.Boolean#0=False) ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:39.9849585Z Timestamp=9802328273636 System.Web.Services.Asmx Information: 0 : Return from SoapExtension Caller: System.Web.Services.Protocols.SoapServerMessage#64042303::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#63331368=[1],System.Boolean#0=False) ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:39.9849585Z Timestamp=9802328287199 System.Web.Services.Asmx Information: 0 : Calling RouteRequest Method: System.Web.Services.Protocols.SoapServerType#63548859::GetMethod(System.String#768149269="http://services.kvh.nl/foo/authenticateUser") Caller: System.Web.Services.Protocols.Soap12ServerProtocolHelper#31339276::RouteRequest() Request Host Address: 127.0.0.1 Request Host Name: web01.kvh.nl Request Url: [POST] http://services.kvh.nl/services/MyWebservice.asmx ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:40.0005585Z Timestamp=9802328288057 System.Web.Services.Asmx Information: 0 : Return from RouteRequest Caller: System.Web.Services.Protocols.Soap12ServerProtocolHelper#31339276::RouteRequest() ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:40.0005585Z Timestamp=9802328288265 System.Web.Services.Asmx Information: 0 : Return from IHttpHandlerFactory.GetHandler Caller: System.Web.Services.Protocols.WebServiceHandlerFactory#31931339::GetHandler() ProcessId=15596 LogicalOperationStack= ThreadId=10 DateTime=2014-05-23T11:13:40.0005585Z Timestamp=9802328288464 解决方法
尝试指定“AnyHttpSoap”而不是“HttpSoap12”.
或者如你所说,如果他们只支持1.2,那么只需从协议中删除“HttpSoap”,而不是添加“HttpSoap12”. <protocols> <remove name="HttpSoap"/> </protocols> This可能有所帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – Razor:如何填写textarea?
- asp.net-mvc – 发生异常后不要刷新会话 – NHibernate
- asp.net-mvc – 在ascx文件中使用Html.RenderPartial()
- Odata V4中的流支持
- asp.net-mvc – asp.net mvc提交时的表单集合
- ASP.NET Forms身份验证的授权安全性
- asp.net – SSO表单身份验证问题.无法解密身份验证Cookie
- asp.net-mvc-2 – 在IIS 7.5上启用html PUT方法
- asp.net-mvc – ASP.Net MVC 4.在单独的程序集中路由控制器
- asp-classic – VBScript条件短路解决方法
- 无需写try/catch,也能正常处理异常
- asp.net – 检查Active Directory密码是否与cook
- asp.net-identity – 在调用SignIn后,可以通过OW
- asp.net – 访问母版页中的祖父母内容占位符
- asp.net-mvc – 无法加载文件或程序集“System.W
- asp.net-mvc – 如何将特定于HTTP-Request的对象
- 为什么要使用ASP.NET MVC 2进行REST服务?为什么
- ASP.NET(C#)Web服务中的异常处理
- asp.net-mvc – User.IsInRole不起作用
- asp.net – 如何在Web App和Windows Form Applic