反序列化 Agatha 请求时出现格式化程序异常
我已经断断续续地为这个问题挠头好一阵子了 现在已经好几天了,我希望有人能提供一些见解。首先, 例外...
活动返回异常:格式化程序引发了 尝试反序列化消息时出现异常:出现错误 尝试反序列化参数 http://tempuri.org/:requests 时。 InnerException 消息为“第 1 行位置 837 中出现错误。元素” 'http://schemas.datacontract.org/2004/07/Agatha.Common.Request' 包含来自映射到名称“http://”的类型的数据 schemas.datacontract.org/2004/07/ MyCompany.MyProduct.Services.Contracts.Customers:ReadAllCustomersRequest'。 解串器不知道映射到该名称的任何类型。 考虑使用 DataContractResolver 或添加对应的类型 'ReadAllCustomersRequest' 到已知类型列表 - 例如,通过 使用 KnownTypeAttribute 属性或将其添加到列表中 传递给 DataContractSerializer 的已知类型。'。请参阅 InnerException 了解更多详细信息。
好吧,这很公平。似乎序列化器不知道我的类型 (ReadAllCustomersRequest)继承自Agatha的Request。奇怪的是,自从 阿加莎应该在配置过程中处理这个问题。我的服务层 配置看起来像这样...
// NOTE: A Unity container (re: the container variable) is built upelsewhere.
var agathaServiceConfiguration = new ServiceLayerConfiguration(new Container(container));
agathaServiceConfiguration.AddRequestHandlerAssembly(typeof(ReadAllCustomersHandler).Assembly);
agathaServiceConfiguration.AddRequestAndResponseAssembly(typeof(ReadAllCustomersRequest).Assembly);
agathaServiceConfiguration.Initialize();
请注意,我的处理程序类型与此代码位于同一程序集中 (我的公司.我的产品.服务)。我的请求和响应类型, 但是,位于不同的程序集中 (我的公司.我的产品.服务.合同)。没什么大不了的。毕竟我 基本上复制了 Brion 的“Hello World”(并引用了中的示例) 阿加莎来源)。
问题是这一切都运行得很好。没有任何错误... 在本地运行时(Win7/VS2010/Cassini)。如果我推送服务器端 Shebang 到 IIS 7.5 站点,但是,我开始收到异常 多于。相同的编译程序集。相同的配置文件。结果不同。 哦,IIS...我多么爱你。
我非常怀疑这是一个阿加莎问题,因为正如我所说,它运行 本地就好了。我只是想知道是否有人知道为什么 当我将其删除到远程服务器时它失败了。我可能失踪了 一些非常非常明显的事情。
哦,不管怎样,IIS 7.5 站点正在托管非 Agatha (嘘!)服务很好。我的 mex 端点枚举得很好, 也。哦,Elmah 在服务器端没有记录任何内容。一切正常 直到我从客户端发送请求。
所以,我的部署有一些问题,但它是 让我难住了。有什么想法吗?
I've been scratching my head with this one off and on for a couple of
days now and I'm hoping someone can offer some insight. First, the
exception...
An exception was returned by an activity: The formatter threw an
exception while trying to deserialize the message: There was an error
while trying to deserialize parameter http://tempuri.org/:requests.
The InnerException message was 'Error in line 1 position 837. Element
'http://schemas.datacontract.org/2004/07/Agatha.Common.Request'
contains data from a type that maps to the name 'http://
schemas.datacontract.org/2004/07/
MyCompany.MyProduct.Services.Contracts.Customers:ReadAllCustomersRequest'.
The deserializer has no knowledge of any type that maps to this name.
Consider using a DataContractResolver or add the type corresponding to
'ReadAllCustomersRequest' to the list of known types - for example, by
using the KnownTypeAttribute attribute or by adding it to the list of
known types passed to DataContractSerializer.'. Please see
InnerException for more details.
Okay, that's fair. Seems like the serializer isn't aware that my type
(ReadAllCustomersRequest) inherits from Agatha's Request. Odd, since
Agatha should be dealing with that during the config. My service layer
config looks like this...
// NOTE: A Unity container (re: the container variable) is built upelsewhere.
var agathaServiceConfiguration = new ServiceLayerConfiguration(new Container(container));
agathaServiceConfiguration.AddRequestHandlerAssembly(typeof(ReadAllCustomersHandler).Assembly);
agathaServiceConfiguration.AddRequestAndResponseAssembly(typeof(ReadAllCustomersRequest).Assembly);
agathaServiceConfiguration.Initialize();
Note that my handler types are in the same assembly as the this code
(MyCompany.MyProduct.Services). My request and response types,
however, are in a different assembly
(MyCompany.MyProduct.Services.Contracts). No big deal. After all, I
basically copied Brion's "Hello World" (and referenced the examples in
the Agatha source).
The thing is that this all works just fine. No errors whatsoever...
when run locally (Win7/VS2010/Cassini). If I push the server-side
shebang out to an IIS 7.5 site, however, I start getting the exception
above. Same compiled assemblies. Same config file. Different result.
Oh, IIS... how I love thee.
I very much doubt this is an Agatha problem since, as I said, it runs
just fine locally. I'm just wondering if anyone has any clue as to why
it fails when I drop it out to a remote server. I'm probably missing
something very, very obvious.
Oh, and for what it's worth, the IIS 7.5 site is hosting non-Agatha
(boo!) services just fine. My mex endpoints are enumerated just fine,
too. Oh, and Elmah records nothing server-side. Everything's normal
until I send a request from the client.
So, there's something about my deployment that's bonked, but it's
got me stumped. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的部署失败了,我的 Global.asax 未正确部署。 叹息...
My deployment was bonked and my Global.asax wasn't deployed correctly. Sigh...