2012-03-19 4 views
2

나는 매우 이상한 문제가 있습니다. 이 방법은 우리가 예외가GetRequestStream()을 시도하는 동안 원격 서버에 연결할 수 없습니다.

string strXMLServer = "https://xxxx.webex.com/WBXService/XMLService"; 

     WebRequest request = WebRequest.Create(strXMLServer); 
     // Set the Method property of the request to POST. 
     request.Method = "POST"; 
     // Set the ContentType property of the WebRequest. 
     request.ContentType = "application/x-www-form-urlencoded"; 

     string strXML = XMLmanager.createXML(User, Password, requestType, sessionKey); 

     byte[] byteArray = Encoding.UTF8.GetBytes(strXML); 

     // Set the ContentLength property of the WebRequest. 
     request.ContentLength = byteArray.Length; 

     // Get the request stream. 
     Stream dataStream = request.GetRequestStream(); //<--- here the exception!! 
     // Write the data to the request stream. 
     dataStream.Write(byteArray, 0, byteArray.Length); 
     // Close the Stream object. 
     dataStream.Close(); 
     // Get the response. 
     WebResponse response = request.GetResponse(); 

"없습니다 가 원격 서버에 연결하기 위해"돌아) GetRequestStream을 (수행하려고하는 동안은, Windows 서비스가 호스팅하는 WCF 호출 방법이

이상한 일은입니다.이 응용 프로그램을 stanalone (콘솔 응용 프로그램)으로 실행하려고하면 아무런 문제가없고 아무런 오류도 발생하지 않습니다! 예외는 WCF에 의해 메서드를 호출 한 경우에만 나타납니다!

답변

2

당신은 이와 비슷한 상황 인 것처럼 SO question입니다. Windows 서비스가 실행되고있는 계정을 확인하십시오. 네트워크 리소스에 액세스 할 가능성이 거의 없습니다.

+0

로컬 시스템에서 실행중인 Windows 서비스 – MoShe

+0

이 경우 HTTP 호출을위한 적절한 액세스 권한을 가진 도메인 계정 또는 컴퓨터 계정 (일반적으로 시스템 이름)이있는 네트워크 서비스로 실행해야합니다 도메인과 적절한 액세스 권한이 있습니다. –

관련 문제