2010-01-11 3 views
0

게시를 통해 webservice에 입력을 보내고 결과를 표시하는 양식 작업 중입니다. 그것은 간단해야하며 localhost에서 잘 작동합니다. 여기웹 서비스를 테스트하기위한 기본 게시물

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 처리기입니다 : 내가 사용하려고 할 때하지만 내가 오류 여기에 500

내 코드가 라이브 전년도 자바 스크립트에서 웹 서비스 및이 잘 작동합니다 :

<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> 
+0

당신이 올바르게 POST 데이터를 인코딩합니까? –

+0

내가 XML 데이터에 대해이 작업을 수행해야 하는가? 내부 XML은 모든 것이 매우 간단합니다. – st78

+0

제발, 당신이 그'data' 변수를 채우는 방법을 보여주세요. –

답변

0

브라우저에서 webservice를 테스트하면 methodname이 url에 추가되지만 게시 할 때는 필요하지 않습니다. 내가 제거 '/ "+ uxAction.SelectedValue'와 (`) (등`HttpUtility.UrlEncode)를 모두 잘 지금 작동하고

관련 문제