BizTalk 与 WCF 服务 - 服务中的空对象
我有一个 ASP.NET Web 服务,并尝试从 BizTalk 调用它。现在我已经成功地实际输入了 Web 服务,但该对象无法映射并且始终返回 NULL。经过尝试和测试,我终于发现导致映射失败的一件事是根节点上的命名空间。现在我不知道如何删除该名称空间,或者尝试调整 Web 服务以使用该名称空间会更好吗?
我的服务方法:
public bool CreateBasket(Basket basket)
{
if(basket == null)
throw new Exception(string.Format("Basket could not be mapped on the service."));
_entities.AddToBaskets(basket);
foreach (var item in basket.Items)
{
_entities.AddToItems(item);
}
return _entities.SaveChanges() > 0;
}
购物篮对象是由实体模型创建的。
此调用有效:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateBasket xmlns="http://tempuri.org/">
<basket xmlns:ns0="http://schemas.datacontract.org/2004/07/OC.SampleCustomer.WCFService" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Data" xmlns:ns2="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/">
<ns0:BillingId>5</ns0:BillingId>
此调用无效:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateBasket xmlns="http://tempuri.org/">
<ns0:basket xmlns:ns0="http://schemas.datacontract.org/2004/07/OC.SampleCustomer.WCFService" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Data" xmlns:ns2="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/">
<ns0:BillingId>5</ns0:BillingId>
编辑 BizTalk 接收我在接收正文中的服务方法中抛出的错误。所以我在 biztalk 服务器上的错误消息是“购物篮无法映射到服务上”。
I have a ASP.NET Webservice and am trying to call it from the BizTalk. Now I've managed for the webservice to actually be entered, but the object can't be mapped and always returns NULL. After trying and testing I finally found out that the one thing that makes it fail the mapping is the namespace on the root node. Now I have no clue how I can remove that namespace or would it be better to somehow try to adjust the webservice to use the namespace?
My Service Method:
public bool CreateBasket(Basket basket)
{
if(basket == null)
throw new Exception(string.Format("Basket could not be mapped on the service."));
_entities.AddToBaskets(basket);
foreach (var item in basket.Items)
{
_entities.AddToItems(item);
}
return _entities.SaveChanges() > 0;
}
The basket object is created by the Entity Model.
This call works:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateBasket xmlns="http://tempuri.org/">
<basket xmlns:ns0="http://schemas.datacontract.org/2004/07/OC.SampleCustomer.WCFService" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Data" xmlns:ns2="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/">
<ns0:BillingId>5</ns0:BillingId>
This call doesn't work:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateBasket xmlns="http://tempuri.org/">
<ns0:basket xmlns:ns0="http://schemas.datacontract.org/2004/07/OC.SampleCustomer.WCFService" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Data" xmlns:ns2="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/">
<ns0:BillingId>5</ns0:BillingId>
Edit
The BizTalk recieves the error I throw in my service method in the recieve body. So my error message on the biztalk server is "Basket could not be mapped on the service."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我放弃了实体框架,并使用为 WCF 服务定义的命名空间创建了自己的对象,现在它可以工作了。感谢您的帮助,我会继续尝试直到我了解更多=)
I gave up on the entity framework and created my own objects with defined namespaces for the WCF service and now it works. Thanks for the help, I'll keep playing around with it till I understand more =)