.NET SOAP消费 - '无法解组类型'

时间:2012-03-02 18:56:00

标签: c# soap soap-client unmarshalling

我正在尝试公开位于此处的Voxbone服务: http://sandbox.voxbone.com/VoxAPI/services/VoxAPI?wsdl

所以我做的是添加一个新项目,右键单击 - 添加服务参考 从那里,生成了一堆代码,我得到了我需要的对象。但是,当调用某些函数(其中一些有效)时,我收到错误:

Could not unmarshall type : cvc-minExclusive-valid: Value '0' is not facet-valid with respect to minExclusive '0' for type 'ID'.

我认为它与ID Property有关......但老实说这对我来说非常神秘。我试过谷歌搜索但无济于事。任何见解都将非常感激。

堆栈跟踪:



Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Api.Voxbone.VoxboneService.VoxAPIIntf.GetDIDGroupList(GetDIDGroupListRequest request)
   at Api.Voxbone.VoxboneService.VoxAPIIntfClient.Api.Voxbone.VoxboneService.VoxAPIIntf.GetDIDGroupList(GetDIDGroupListRequest request) in {FileSystem}\Reference.cs:line 7471
   at Api.Voxbone.VoxboneService.VoxAPIIntfClient.GetDIDGroupList(GetDIDGroupList GetDIDGroupList1) in {FileSystem}\Reference.cs:line 7477
   at Api.Voxbone.VBService.GetDIDGroups() in {FileSystem}/VBService.cs:line 60

The '{FileSystem}' was snipped for privacy.

2 个答案:

答案 0 :(得分:1)

在WSDL中搜索minExclusive。这是根据<!-- RESTRICTIONS -->的评论。你会看到<xsd:minExclusive value="0"/>,这意味着不能为ID分配0或更小的值(因为最小值是 exlusive ,所以它不包括0) 。

一种简单的 hackish 解决方法,就是下载WSDL,更改<xsd:minExclusive value="0"/> <xsd:minExclusive value="-1"/>,然后重新添加指向项目的Web引用修改后的WSDL而不是原始的。

解决问题的正确方法是弄清楚为什么会为ID分配0的值,也许该方法在找不到您请求的对象时会返回该值?不要相信API遵守自己的限制!

答案 1 :(得分:0)

.NET是正确的。 “0”不是ID的有效值。