.asmx支持post请求或者get请求调用(WebService "因 URL 意外地以 结束,请求格式无法识别" 的解决方法)

使用Post调用以asmx形式提供的webservice时,在本机调试没有调用问题。一旦部署至服务器后会提示如下信息:

<html>
    <head>
        <title>因 URL 意外地以“/GetCertByToken”结束,请求格式无法识别。</title>
        <meta name="viewport" content="width=device-width" />
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
         @media screen and (max-width: 639px) {
          pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
         }
         @media screen and (max-width: 479px) {
          pre { width: 280px; }
         }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>“/”应用程序中的服务器错误。<hr width=100% size=1 color=silver></H1>

            <h2> <i>因 URL 意外地以“/GetCertByToken”结束,请求格式无法识别。</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> 说明: </b>执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

            <br><br>

            <b> 异常详细信息: </b>System.InvalidOperationException: 因 URL 意外地以“/GetCertByToken”结束,请求格式无法识别。<br><br>

            <b>源错误:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code>

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。</code>

                  </td>
               </tr>
            </table>

            <br>

            <b>堆栈跟踪:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>

[InvalidOperationException: 因 URL 意外地以“/GetCertByToken”结束,请求格式无法识别。]
   System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +675
   System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +259
   System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +81
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +375
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128
</pre></code>

                  </td>
               </tr>
            </table>

            <br>

            <hr width=100% size=1 color=silver>

            <b>版本信息:</b> Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.7.3282.0

            </font>

    </body>
</html>

  

解决方案:

修改web.config文件,增加如下内容即可。

<system.web>
     <webServices>
          <protocols>
              <add name="HttpGet" />
              <add name="HttpPost" />
              <add name="Unknown" />
              <add name="HttpSoap" />
          </protocols>
      </webServices>
  </system.web>

  

原文地址:https://www.cnblogs.com/netwenchao/p/10762190.html

时间: 2024-08-27 04:59:45

.asmx支持post请求或者get请求调用(WebService "因 URL 意外地以 结束,请求格式无法识别" 的解决方法)的相关文章

WebService &quot;因 URL 意外地以 结束,请求格式无法识别&quot; 的解决方法

问题出现的前提条件: 1.使用XMLHttpRequest向服务端发送请求,未正常返回信息 2.使用FireBug发现如标题所描述的问题 解决办法: 在WebConfig->system.web下添加webServices节点,入下所示 <webServices>          <protocols>              <add name= "HttpGet" />               <add name= "

Java调用存储过程时报 The user specified as a definer (&#39;root&#39;@&#39;%&#39;) does not exist 解决方法

Caused by: java.sql.SQLException: The user specified as a definer (''@'') does not exist        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)        at com.mysql

(转)jdbc 调用 sql server 的存储过程时“该语句没有返回结果集”的解决方法

本文转载自:http://hedyn.iteye.com/blog/856040 在JDBC中调用SQL Server中的存储过程时出现如下异常: com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171) at com.microsof

c++ 调用pthread_create函数时,传入类中的成员报错。解决方法。

1.问题出现 我想把我的c程序转成c++的方式写,因为我觉得c++的面向对象方式特别的好用. 然后我开始移植了,当我想把在一个类函数中调用pthread_create来创建一个类. 我给的参数是 s=pthread_create(&id,NULL,run,NULL); //函数原型 void * THREAD_433::run(void *arg) { void * ret; using namespace std; cout<<"hello!\r\n"; retu

使用ajax和urlconnection方式调用webservice服务

<html> <head> <title>使用ajax方式调用webservice服务</title> <script> var xhr = new XMLHttpRequest(); function sendAjax(){ var url = "http://192.168.13.66:8080/hello";//webservice服务的地址 var requestBody = '<soapenv:Envelope

其他调用WebService方法

Ajax调用WebService 但是这样会出现跨域请求问题 1.  什么是跨域请求?   Host 1. sina.com--=->baidu.com/xxx.jsp 2. localhost----à192.168.42.165 2. 解决ajax跨域请求webservice的问题? 在客户端应用中使用java编码去请求webservice, 在页面中去请求自己的后台 Jquery调用WebService HttpURLConnection调用WebService

axis2调用webService几种方式

主要有三种方式: 第一RPC方式,不生成客户端代码 第二,document方式,不生成客户端代码 第三,用wsdl2java工具,生成客户端方式调用 java代码: package samples.quickstart.client; import javax.xml.namespace.QName; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apa

JAVA调用webservice方法(axis)

项目需求上需要调用另一个合作伙伴的webservice接口,之前用的是sax的调用方式,开始摸索这个,感觉这个也挺简单的,现在把自己的实现过程分享给大家,写的不好的地方,望大家勿喷. 详细代码如下: package com.ancs.oa; import java.util.Date; import javax.xml.namespace.QName; import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.En

C# 使用 HttpPost 请求调用 WebService

原文:C# 使用 HttpPost 请求调用 WebService 之前调用 WebService 都是直接添加服务引用,然后调用 WebService 方法的,最近发现还可以使用 Http 请求调用 WebService.这里还想说一句,还是 web api 的调用简单. WebService 服务端代码: public class WebServiceDemo : System.Web.Services.WebService { [WebMethod] public string Hello