首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“Microsoft.Web.Services3.Addressing.Address”不能序列化

“Microsoft.Web.Services3.Addressing.Address”不能序列化
EN

Stack Overflow用户
提问于 2009-11-13 20:39:26
回答 2查看 1.3K关注 0票数 2

我正在尝试为WSE3 3/ASMX web服务编写WCF包装器web服务。丑陋的原因是第三方供应商不支持SSL,而这正是BizTalk 2009 WCF适配器与with协同工作所需要的。所以如果供应商不改变-我需要打电话给当地的WCF网络服务.

我遵循本文将WSE3代理构建器内置到VS2008:http://blogs.imeta.co.uk/jyoung/archive/2008/08/29/345.aspx中,我对供应商的.asmx远程web服务进行了web引用。

我在本地构建和发布我的webservice,并尝试在浏览器中打开它,并得到以下错误:

System.ServiceModel.Description.DataContractSerializerOperationBehavior System.InvalidOperationException:在调用WSDL导出扩展时抛出异常: System.Runtime.Serialization.InvalidDataContractException:合同:http://tempuri.org/:IValuationService -->System.Runtime.Serialization.InvalidDataContractException:类型'Microsoft.Web.Services3.Addressing.Address‘不能序列化。考虑用DataContractAttribute属性标记它,并用DataMemberAttribute属性对它的所有成员进行标记。有关其他受支持类型,请参阅文档。

如何使没有编写('Microsoft.Web.Services3.Addressing.Address')的对象可序列化?有可能完成我正在尝试的事情吗?

谢谢,

尼尔·沃尔特斯

补充资料-2009年11月16日星期一:

代码语言:javascript
复制
[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.WebServicesClientProtocol进行“定义”时,唯一能找到“Microsoft.Web.Services3.Addressing.Address”的任何引用的地方都在这里。

代码语言:javascript
复制
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公开它。但诀窍在于,供应商web服务有许多大型复杂对象--这些对象现在都是从Microsoft.Web.Services3.WebServicesClientProtocol继承的(因为我使用的是WS3代码生成器)。我真的不想再手动构建它们了。在上面的例子中,"ValuationService“只是这样的对象之一。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-11-16 15:44:31

好吧,问题出在这里。这个应用程序暴露了4个服务和数十种方法,这是我第一次从WCF中使用WSE3,这个应用程序的复杂性让我变得有些迷茫和迷失。

错误是因为我编写的包装程序试图返回ValuationService本身。那是个愚蠢的错误。Microsoft.Web.WebServices3.WebServicesClientProtocol确实实现了ValuationService,其中包括导致问题的寻址类。

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

票数 1
EN

Stack Overflow用户

发布于 2009-11-14 13:07:42

你不能让某件事“在事实发生之后”被连载。问题是:你需要那个“地址”做什么?

您是否可以更改WCF包装器,以便将地址(如果我怀疑是URL )作为字符串从客户端传递到WCF服务,然后在WCF服务类中创建" address“实例?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1731756

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档