2013-12-13 5 views
0

우리가 가지고있는 DLL의 특정 유형을 사용하는 웹 서비스가 있습니다. 그래서 예를 들어 Visual Studio에서 우리의 웹 서비스 솔루션은 다음과 같습니다 웹 서비스에서 DLL의 유형을 노출하십시오.

Solution 
    ACMEWebService (proj) 
    Utils (proj) 

는 다음 나는 Util 클래스에 존재하는 특정 유형을 예상하고 내 ACMEWebService에서 WebMethod 있습니다.

[WebMethod] 
public void SomeWebMethod (int Id, CustomDateClass date) 
{ 
    // my code here 
} 

그래서 CustomDateClassUtils 프로젝트에 위치한 클래스 : 그것은 다음과 같이 보입니다. 그 Utils 프로젝트는 단순히 DLL 파일을 만듭니다.


내 클라이언트 응용 프로그램이 웹 서비스를 참조합니다. 그것이 무엇을하면이 같은 것을 찾고, 소위 프록시 클래스를 생성하는 것입니다 : 그 프록시 클래스에서

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://acme/Services")] 
public partial class CustomDateClass { 
    private short yearField; 
    private byte monthField; 

    public short Year { 
     get { 
      return this.yearField; 
     } 
     set { 
      this.yearField = value; 
     } 
    } 

    public byte Month { 
     get { 
      return this.monthField; 
     } 
     set { 
      this.monthField = value; 
     } 
    } 
} 

[System.Web.Services.Protocols.SoapHeaderAttribute("CustomSoapHeaderValue")] 
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://acme/Services/SomeMethod" ...)] 
public void SomeMethod(int id, CustomDateClass date) { 
    object[] results = this.Invoke("SomeMethod", new object[] { 
       id, 
       date}); 
} 

내가 또한 CustomDateClass 클래스와 웹 방법 SomeWebMethod(int Id, CustomDateClass date)를 참조하십시오.

문제는 그러나 IS, 프록시 클래스에서이 메소드는 Utils DLL에서 CustomDateClass 객체를 기대하지 않지만, 프록시 클래스 네임 스페이스에서 ...

웹을 강제 할 수있는 방법이 있다는 것입니다 Utils DLL에서 유형을 노출하는 서비스?

그럼 간단히 말해 내 CLient App의 Utils.dll을 참조하고 Utils DLL의 인스턴스 인 객체를 이제 Proxy 클래스에서 참조되는 클래스 대신 웹 서비스로 전달할 수 있습니다. .

답변

1

프록시 클래스 생성기 (웹 서비스 참조 마법사라고도 함)에는 가능한 경우 기존 유형을 다시 사용할 수있는 확인란이 있습니다. dll을 참조하고이 확인란을 활성화하여 웹 서비스 참조를 업데이트하십시오.

0

프록시 클래스가있는 프로젝트에 Util dll에 대한 참조를 추가 할 수 있습니다. 그런 다음 메서드 서명을 변경하여 Util dll의 개체를 수락 할 수 있습니다. Util dll의 클래스 이름과 다이어그램이 웹 서비스가 기대하는 것과 비슷하다면 문제가되지 않습니다.