2012-03-19 134 views
2

私は非常に奇妙な問題があります。GetRequestStream()を試行中にリモートサーバーに接続できません

方法はGetRequestStreamを(実行しようとしながら、私は、WindowsサービスによってホストされているWCFによって呼び出されるメソッドを持っている)我々は

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(); 

例外「リモートサーバーに接続できません」取り戻します奇妙なことはです。このアプリケーションをスタナロン(コンソールアプリケーション)として実行しようとすると、問題はなくエラーも発生しません。例外は、私がWCFによってメソッドを呼び出した場合にのみ表示されます。

答えて

2

このような状況のようですが、SO questionです。 Windowsサービスが実行されているアカウントを確認します。ネットワークリソースにアクセスできない可能性があります。

+0

ローカルシステムで実行されているWindowsサービス – MoShe

+0

この場合、HTTP呼び出しを行う適切なアクセス権を持つドメインアカウントまたはマシンアカウント(通常はマシン名)が含まれているネットワークサービスのいずれかを使用して実行する必要がありますドメインと適切なアクセス権を持っています。 –

関連する問題