Asp.net 测试web服务的基本post

Asp.net 测试web服务的基本post,asp.net,web-services,post,Asp.net,Web Services,Post,我正在制作表单,它通过post向webservice发送输入并显示结果。它必须简单,并且在本地主机上运行良好。但当我尝试再次使用它时,我有错误500 这是我的密码: WebRequest request = WebRequest.Create("http://localhost:3192/WebServices/Export.asmx/" + uxAction.SelectedValue); UTF8Encoding encoding = new UTF8Enc

我正在制作表单,它通过post向webservice发送输入并显示结果。它必须简单,并且在本地主机上运行良好。但当我尝试再次使用它时,我有错误500

这是我的密码:

 WebRequest request = WebRequest.Create("http://localhost:3192/WebServices/Export.asmx/" + uxAction.SelectedValue);
                UTF8Encoding encoding = new UTF8Encoding();
                byte[] data = encoding.GetBytes(uxRequest.Text);
                request.Method = "POST";
                request.ContentType = "text/xml; charset=utf-8";
                request.ContentLength = data.Length;

                Stream requestStream = request.GetRequestStream();
                requestStream.Write(data, 0, data.Length);
                requestStream.Flush();
                requestStream.Close();

                WebResponse response = request.GetResponse();
                Stream newStream = response.GetResponseStream();
                byte[] responseArray = new byte[response.ContentLength];
                newStream.Read(responseArray, 0, (int)response.ContentLength);
                newStream.Close();

                uxResponse.Text = encoding.GetString(responseArray);
这是关于错误的信息

 Exception information: 
        Exception type: InvalidOperationException 
        Exception message: Request format is unrecognized for URL unexpectedly ending in '/GetProjectTypes'. 

    Request information: 
        Request URL: http://sitename.com/WebServices/Export.asmx/GetProjectTypes 
        Request path: /WebServices/Export.asmx/GetProjectTypes 
        User host address: 93.73.249.242 
        User:  
        Is authenticated: False 
        Authentication Type:  
        Thread account name: NT AUTHORITY\NETWORK SERVICE 


Thread information: 
    Thread ID: 1 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
   at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
我还使用http处理程序从javascript访问web服务,这很好:

<add verb="GET,HEAD,POST*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

这是我的请求数据。有或没有异常都是一样的。Webservice没有任何参数

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetProjectTypes xmlns="http://sitename.com/WebServices/Export.asmx" />
  </soap:Body>
</soap:Envelope>

当我们在浏览器中测试webservice时,它会将methodname添加到url中,但当我们发布时,这是不需要的。
我删除了“/”+uxAction.SelectedValue”,现在一切都正常了

您的帖子数据编码正确吗(
HttpUtility.UrlEncode()
等)?我应该为xml数据执行此操作吗?在xml内部,一切都非常简单请演示如何填充
数据
变量它类似于:我从示例SOAP 1.1指令中获取它。但是,没有此数据,结果是相同的。我的方法没有任何参数