2013-07-31 3 views
0

다른 서버의 코드 숨김 코드에서 원격 웹 메소드 (asmx)를 호출하려고합니다. 두 번째 요구 사항은 하나의 문자열과 pdf 파일을 webmethod에 전달하고 webmethod에서이를 사용하는 것입니다.C에서 원격 웹 메소드 호출 #

내가 가진 전부는 Testing.asmx에있는이 간단한 웹 메소드입니다.

[WebMethod] 
public string TestPdf() 
{ 
    return "Hello World"; 
} 

은 누구도 날이의 WebMethod (: http://mydomain.com/Testing.asmx/TestPdf URL)를 호출하는 방법을 알려 주시기 바랍니다 수 있습니까?

"hello world"를 반환하기 전에 pdf 파일과 문자열 매개 변수를 webmethod에 전달하고 검색 할 수 있습니다.

+1

[WebClient 클래스] (http://msdn.microsoft.com/en-us/library/system.net.webclient (v = vs.110) .aspx)를 살펴보십시오. –

+0

http://johnwsaunders3.wordpress.com/2009/05/17/how-to-consume-a-web-service/ 참조하십시오. –

답변

0

이 용도로 사용하려면 httpget이 사용 가능해야합니다.

private void DownloadInformation() 
{ 
WebClient Detail = new WebClient(); 
Detail.DownloadStringCompleted += new  DownloadStringCompletedEventHandler(DownloadStringCallback2); 
Detail.DownloadStringAsync(new Uri("http://link/")); 
} 

private static void DownloadStringCallback2 (Object sender, DownloadStringCompletedEventArgs e) 
{ 
    // If the request was not canceled and did not throw  
    // an exception, display the resource.  
    if (!e.Cancelled && e.Error == null) 
    { 
     string textString = (string)e.Result; 

     Console.WriteLine (textString); 
    } 
} 
+0

제 질문은 codebehind에서이 webmethod를 호출하는 방법입니다. 둘째, 매개 변수를 웹 메소드에 전달하는 방법. – pessi

+0

http://stackoverflow.com/questions/1224672/how-to-call-a-web-service-method와 같은 뜻입니까? – LosManos

관련 문제