우리가 가지고있는 DLL의 특정 유형을 사용하는 웹 서비스가 있습니다. 그래서 예를 들어 Visual Studio에서 우리의 웹 서비스 솔루션은 다음과 같습니다 웹 서비스에서 DLL의 유형을 노출하십시오.
Solution
ACMEWebService (proj)
Utils (proj)
는 다음 나는
Util
클래스에 존재하는 특정 유형을 예상하고 내
ACMEWebService
에서
WebMethod
있습니다.
[WebMethod]
public void SomeWebMethod (int Id, CustomDateClass date)
{
// my code here
}
그래서 CustomDateClass
가 Utils
프로젝트에 위치한 클래스 : 그것은 다음과 같이 보입니다. 그 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
객체를 기대하지 않지만, 프록시 클래스 네임 스페이스에서 ...
그럼 간단히 말해 내 CLient App의 Utils.dll을 참조하고 Utils DLL의 인스턴스 인 객체를 이제 Proxy 클래스에서 참조되는 클래스 대신 웹 서비스로 전달할 수 있습니다. .