我试图写一个WSE3 / ASMX Web服务的WCF包装的Web服务。 [丑陋的原因是,第三方供应商将不会支持SSL,这是什么需要为BizTalk 2009年WCF适配器WS-Security的工作。因此,如果供应商不改变 - 我需要调用本地WCF web服务...]

我跟着这篇文章来获得内置于VS2008的WSE3代理建设者: http://blogs.imeta.co.uk/ jyoung /存档/ 2008/8月29日/ 345.aspx 我做一个Web引用到供应商的远程的.asmx Web服务。

我建立并在本地发布我的web服务,只是尽量把它在浏览器中,并得到这个错误:

  

System.InvalidOperationException:一个   例外是在呼叫抛出的   WSDL出口扩展:   System.ServiceModel.Description.DataContractSerializerOperationBehavior   合同:    http://tempuri.org/:IValuationService   ----> System.Runtime.Serialization.InvalidDataContractException:   类型   'Microsoft.Web.Services3.Addressing.Address'   无法序列。考虑标记   它与DataContractAttribute   属性,标志着其所有   会员想要序列化与   DataMemberAttribute属性。看到   在Microsoft .NET Framework   支持其他文件   类型。

我怎样才能让一个对象,我没有写(“Microsoft.Web.Services3.Addressing.Address”)可序列化?是否有可能完成什么,我想?

谢谢,

尼尔沃尔特斯


附加信息 - 星期一二○○九年十一月一十六日:


[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”任何引用唯一的地方 在这里,对元数据时,我做了一个“去定义”的Microsoft.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”只是这样的对象中的一个。

有帮助吗?

解决方案 2

好的,这是问题所在。我开始有点浑浊,并在此应用程序暴露4和几十个方法的复杂性丢失,以及曾经使用WSE3首次从WCF。

是错误,因为我写的包装试图返回ValuationService本身。这是一个愚蠢的错误。该ValuationService没有实现,其中包括寻址类是造成问题的Microsoft.Web.WebServices3.WebServicesClientProtocol。

该包装应该使用ValuationService作为客户端,并且仅返回估值(或ValuationResult)。该valuationResult当然只是由字符串,小数,布尔值等的对象......可序列化。

其他提示

您不能进行“事后”的东西序列化。现在的问题是:你需要什么是“地址”的呢?

那你能不能改变你的WCF的包装,这样你会传递一个地址(如果那是因为我怀疑的URL)从你的客户你的WCF服务的字符串,然后内创建“地址”的一个实例,你WCF服务类

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top