2011-03-04 11 views
1

클라이언트가 .net asmx webservice에 위치 정보를 제공했습니다. 내 웹 응용 프로그램에서 웹 서비스와 통신하기 위해 사용하는 라이브러리를 만들었습니다. 내 라이브러리에서SoapHttpClientProtocol을 사용하여 원격 서버에 연결할 수 없습니다.

, 나는이 자신의 서비스

using (vendorproxy.vendorproxy wsProxy = new vendorproxy.vendorproxy()) 
{ 
    wsProxy.Credentials = new System.Net.NetworkCredential(uname, pwd); 

    using (Stream xmlStream = xmlUtil.GenerateStreamFromString(
     wsProxy.GetData(index))) 
    { 
     // 
    } 
} 

public Stream GenerateStreamFromString(String inputString) 
{ 
    byte[] bytes = UTF8Encoding.UTF8.GetBytes(inputString); 
    MemoryStream strm = new MemoryStream(); 
    strm.Write(bytes, 0, bytes.Length); 
    return strm; 
} 

클라이언트가 서비스를 테스트하기 위해 테스트 응용 프로그램을 개발하고 작동을 호출하는 내 코드입니다 ASMX

에 웹 참조를 만들었습니다. 그러나 시스템에 배포 할 때 내 애플리케이션이 실패합니다. 클라이언트가 네트워크 외부의 서비스를 노출하지 않았으므로 코드를 단계별로 실행할 수 없습니다. 이것은 xml 파일과 wsdl을 통해서만 샘플 출력을 제공함으로써 개발되었습니다.

예외 세부 정보 :

at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)  
at System.Net.HttpWebRequest.GetRequestStream()  
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(
    String methodName, Object[] parameters)  

서비스에 웹 심판이 내 클래스 라이브러리의 App.config 및 호출을 수행 한. 클래스 라이브러리가 해결 내 웹 응용 프로그램

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > 
      <section name="clientService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
     </sectionGroup> 
    </configSections> 
    <system.serviceModel> 
     <bindings /> 
     <client /> 
    </system.serviceModel> 
    <applicationSettings> 
     <clientService.Properties.Settings> 
      <setting name="clientService_client_client" serializeAs="String"> 
       <value>http://localhost:2362/client.asmx</value> 
      </setting> 
     </clientService.Properties.Settings> 
    </applicationSettings> 
</configuration> 

에 의해 사용됩니다 내가

using (vendorproxy.vendorproxy wsProxy = new vendorproxy.vendorproxy()) 
{ 
    wsProxy.Credentials = new System.Net.NetworkCredential(uname, pwd); 
    wsProxy.URL = [correct asmx location read from config file] 
    //not sure why it would not automatically pick up from config file. 
} 
+0

호출 응용 프로그램이 배포 된 서버에서 서비스가있는 주소를 핑 (ping) 할 수 있습니까? – FarligOpptreden

+0

전체 예외 메시지가 좋을 것입니다. 부분 스택 추적 만 제공했습니다. –

+0

서비스는 http : //machinename/somewhere/clientservice/somemthing.asmx에 있으며, 이름이 변경되었거나 위에 일치하지 않을 수 있습니다. 핑 machinename 작동합니다. 문제 없음 – user644702

답변

0

내 추측에게

using (vendorproxy.vendorproxy wsProxy = new vendorproxy.vendorproxy()) 
{ 
    wsProxy.Credentials = new System.Net.NetworkCredential(uname, pwd); 
} 

에서 내 원래의 코드를 수정 한 후이 일 (기반으로 제한된 예외 정보) :

webservice를 서버에 배치 할 때 webservice에 연결하는 데 사용되는 위치를 업데이트해야합니다.

위치는 일반적으로 web.config 또는 app.config 내부의 URI/URL입니다.

+0

해당 시스템에 배포 할 때. asmx가있는 곳을 가리 키도록 library.dll.config 파일을 업데이트했습니다. – user644702

+0

또한 필자는 자신의 네트워크에 메모를 남기면서 시스템에 액세스 할 수 없었습니다. wsdl 및 해당 서비스에서 전송중인 데이터를 나타내는 xml 파일을 사용하여 만 개발했습니다. – user644702

+0

테스트 응용 프로그램에 사용하는 URI/URL이 있습니까? –

1

프록시에 외부 주소로 연결하는 데 문제가있을 수 있으므로 설정에이 내용을 추가해야 할 수도 있습니다.

<system.net> 
    <defaultProxy> 
     <proxy 
      autoDetect = "true" /> 
    </defaultProxy> 
    </system.net> 

안부

+0

@lain : 내 웹 앱은 웹 서비스 프로젝트에 연결되는 클래스 라이브러리를 사용합니다. 그리고 이것은 서비스에 대한 웹 참조가있는 클래스 라이브러리의 app.config입니다. – user644702

+0

구성 정보로 내 주요 이야기가 업데이트되었습니다. – user644702

2

난 강력 비슷한 질문에 this answer을 시도 할 것을 촉구한다. 코드를 변경하지 않고 app.config 파일의 한 줄만 있습니다.

관련 문제