我有一個Web服務,它使用我們擁有的DLL中的特定類型。因此,例如我們在Visual Studio中的Web服務解決方案是這樣的:從Web服務公開DLL的類型
Solution
ACMEWebService (proj)
Utils (proj)
然後我在我的ACMEWebService
其中預計存在於Util
類某一類型WebMethod
。它看起來是這樣的:
[WebMethod]
public void SomeWebMethod (int Id, CustomDateClass date)
{
// my code here
}
所以CustomDateClass
是位於Utils
項目的類。 Utils
項目只是構建到一個DLL文件。
我的客戶端應用程序引用了Web服務。它所做的是它產生所謂的代理類,看起來像這樣:
[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
類和Web方法SomeWebMethod(int Id, CustomDateClass date)
。
問題不過是,是從代理類此方法不期望從Utils
DLL一個CustomDateClass
對象,但代理類的命名空間......
有沒有辦法迫使網絡從Utils DLL公開該類型的服務?
然後,我可以簡單地引用我的CLient應用程序中的Utils.dll,並將實例中的實例從Utils DLL傳遞迴Web服務,而不是現在代理類中引用的類。