2010-02-25 4 views
11

웹 참조는 웹 사이트의 web.config에 정의되어 있지 않습니다. 편집 할 수있는 "웹 참조"폴더에 "Reference.map"라는 구성 파일이 있지만 편집 할 때 아무 일도 일어나지 않습니다. 폴더에있는 WSDL 파일의 이름을 변경하여 새 파일을 가져올지를 확인하기까지했습니다. 그렇지 않았습니다.프로덕션 .NET 웹 사이트에서 웹 참조를 변경하려면 어떻게합니까?

참조 된 웹 서비스의 URL을 변경하기 위해서 빌드를해야합니까?

답변

19

웹 참조를 정적 또는 동적 URL로 표시 할 수 있습니다. 동적을 선택하면 URL이 web.config에 추가되며,이 URL을 제작 환경에서 변경할 수 있습니다.

정적으로 표시되어 있으면 이진으로 컴파일되며 다시 작성하지 않으면 변경할 수 없습니다.

동적 인 경우 코드는 동적 URL을 찾은 다음 찾을 수없는 경우 기본 원본을 사용합니다. 컴팩트 프레임 워크에

<applicationSettings> 
    <MySystem.Properties.Settings> 
     <setting name="MySystem_MyService" serializeAs="String"> 
      <value>http://mysystem/service.asmx</value> 
     </setting> 
    </MySystem.Properties.Settings> 
</applicationSettings> 
+0

따라서, 당신은 단지 웹 설정 등에 항목을 추가 할 수 있습니다 URL을 동적으로 표시했지만 여전히 웹 구성에없는 대답으로 표시합니다. 다른 아이디어? – JoshBaltzell

+0

더 많은 정보를 추가했습니다. 기본적으로 web.config에 줄을 추가하기 만하면됩니다. 정확한 구문은 웹 참조에 따라 다릅니다. –

+0

웹 참조를 제거하고 다시 추가하기 만하면 web.config가 다시 작성됩니다. 그것은 읽기 전용이나 아무것도 아니지만 있는지 확인하십시오. –

0

당신이 WebService에 당신의 자신의 클래스에 설정 파일을 읽을 수 있습니다 : 나는 후 실현

public partial class YourService : System.Web.Services.Protocols.SoapHttpClientProtocol { 

    /// <remarks/> 
    public HandTerminalService() { 
     string appSettings = string.Concat(Assembly.GetExecutingAssembly().GetName().CodeBase, ".config"); 
     XmlDocument xmlDocument = new XmlDocument(); 
     xmlDocument.Load(appSettings); 
     XmlNode xmlNode = xmlDocument.SelectSingleNode("//configuration/appSettings/add[@key = 'Proxy.YourServiceService']"); 
     if (xmlNode.Attributes["value"].Value != null) 
     { 
      this.Url = string.Concat(xmlNode.Attributes["value"].Value, ""); 
     } else 
     { 
      this.Url = "http://<IP_or_DNS-Name>:<Port>/YourService.asmx"; 
     } 
    } 
관련 문제