我正在嘗試爲WSE3/ASMX Web服務編寫WCF包裝Web服務。 [醜陋的原因是,第三方供應商不支持SSL,而這正是BizTalk 2009 WCF適配器與WS-Security一起使用所需的。因此,如果供應商不改變 - 我需要調用本地WCF web服務...]'Microsoft.Web.Services3.Addressing.Address'無法序列化
我跟着這篇文章來獲得WSE3代理生成器內置到VS2008: http://blogs.imeta.co.uk/jyoung/archive/2008/08/29/345.aspx 我做一個網頁參考供應商的.asmx遠程Web服務。
,製作並在本地發佈我的web服務,只是儘量把它在瀏覽器中,並得到這個錯誤:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: http://tempuri.org/:IValuationService ----> System.Runtime.Serialization.InvalidDataContractException: Type 'Microsoft.Web.Services3.Addressing.Address' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types.
我怎樣才能讓一個對象,我沒有寫(「微軟.Web.Services3.Addressing.Address')可序列化?是否有可能完成我所嘗試的?
感謝,
尼爾·沃爾特斯
附加信息 - 星期一2009年11月16日:
[ServiceContract]
public interface IValuationService
{
[OperationContract]
ExpressLync.ValuationServiceWse GetPropertyInfoSourceRecordPolicyNum(string PolicyNumber);
}
// end of interface
// here is part of reference.cs...
public partial class ValuationServiceWse : Microsoft.Web.Services3.WebServicesClientProtocol {
...
我能找到的任何參考什麼那麼以往任何時候都只有一個地方到'Microsoft.Web.Services3.Addressing.Address' 在這裏,當我做一個「定義」Microso的元數據ft.Web.Services3.WebServicesClientProtocol
using Microsoft.Web.Services3.Addressing;
using Microsoft.Web.Services3.Design;
using System;
using System.Net;
using System.Web.Services.Protocols;
using System.Xml;
namespace Microsoft.Web.Services3
{
public class WebServicesClientProtocol : SoapHttpClientProtocol
{
public WebServicesClientProtocol();
public EndpointReference Destination { get; set; }
public Pipeline Pipeline { get; set; }
public SoapContext RequestSoapContext { get; }
public bool RequireMtom { get; set; }
public SoapContext ResponseSoapContext { get; }
public string Url { get; set; }
public bool UseDefaultCredentials { get; set; }
public TSecurityToken GetClientCredential<TSecurityToken>() where TSecurityToken : Microsoft.Web.Services3.Security.Tokens.SecurityToken;
protected override XmlReader GetReaderForMessage(SoapClientMessage message, int bufferSize);
public TSecurityToken GetServiceCredential<TSecurityToken>() where TSecurityToken : Microsoft.Web.Services3.Security.Tokens.SecurityToken;
protected override WebRequest GetWebRequest(Uri uri);
protected override WebResponse GetWebResponse(WebRequest request);
protected override WebResponse GetWebResponse(WebRequest request, IAsyncResult result);
protected override XmlWriter GetWriterForMessage(SoapClientMessage message, int bufferSize);
public void SetClientCredential<TSecurityToken>(TSecurityToken clientToken) where TSecurityToken : Microsoft.Web.Services3.Security.Tokens.SecurityToken;
public void SetPolicy(Policy policy);
public void SetPolicy(string policyName);
public void SetServiceCredential<TSecurityToken>(TSecurityToken serviceToken) where TSecurityToken : Microsoft.Web.Services3.Security.Tokens.SecurityToken;
}
}
因此,換句話說,我該如何擺脫 'Microsoft.Web.Services3.Addressing.Address' 的? 似乎EndpointReference位於'Microsoft.Web.Services3.Addressing.Address'對象中。所以如果我使用WSE3生成的代碼,它會嘗試序列化它。
所以我認爲解決方案將是寫另一個WSE3免費包裝 - 並通過WCF公開它。但訣竅是供應商Web服務有許多大而複雜的對象 - 現在它們都從Microsoft.Web.Services3.WebServicesClientProtocol繼承(因爲我使用的是WS3代碼生成器)。我真的不想再次手動構建它們。在上面的例子中,「ValuationService」就是這樣的對象之一。
如何擺脫「Microsoft.Web.Services3.Addressing.Address」?這似乎是「插入本身,這是我想具體包括的任何東西。 – NealWalters 2009-11-16 14:29:28
解決 - 看到我的答案如下。 – NealWalters 2009-11-16 15:44:44
好吧,很高興你能解決它! – 2009-11-16 19:56:00