【发布时间】:2018-05-22 15:35:49
【问题描述】:
调用Workday API Assign_Costing_Allocation时突然出现XML生成错误:
System.ServiceModel.CommunicationException
HResult=0x80131501
Message=There was an error in serializing body of message Assign_Costing_AllocationInput: 'There was an error generating the XML document.'. Please see InnerException for more details.
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at PostBudget.PayrollService.PayrollPort.Assign_Costing_Allocation(Assign_Costing_AllocationInput request)
...
Inner Exception 1:
InvalidOperationException: There was an error generating the XML document.
Inner Exception 2:
InvalidOperationException: The type PostBudget.PayrollService.Tenanted_Payroll_WorktagObjectIDType was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
PostBudget.PayrollService.Tenanted_Payroll_WorktagObjectIDType 在 References.cs 中提供,自动生成并具有序列化标签:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.2612.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:com.workday/bsvc")]
public partial class Tenanted_Payroll_WorktagObjectIDType : object, System.ComponentModel.INotifyPropertyChanged { ... }
如何调试这个?我能做些什么来完成这项工作?
【问题讨论】:
-
我认为代码可以正常工作。我怀疑代理有问题。证书的日期可能已过期。检查你的 IE 证书,看看是否有任何过期。如果您使用 IE 访问该站点,该 URL 是否有效?
-
@jdweng 出错的对象实际上是被序列化的更大对象的一部分。更正了问题。不,它在此配置中不起作用。如果我删除 Tenanted_Payroll_WorktagObjectIDType 实例,一切正常。
-
代码看起来好像遇到了代理错误。我会使用像wireshark或fiddler这样的嗅探器来查看应用程序是否正在尝试与代理服务器通信。您将看到一个请求被发送到代理并且没有响应表明代理没有运行(或者您可能使用了错误的 ip),或者您会得到一个响应,然后该响应可能会表明真正的根本原因的错误。
-
不接近通讯部分。错误在于将有效负载对象转换为 XML。在创建传出消息之前请求失败。
-
如果没有首先连接到代理服务器以从代理获取密钥,则无法创建 xml。这就是异常消息所说明的内容。 soap xml 包含一个加密部分,这就是发生故障的地方。不知道是连接错误还是你PC上的证书过期了。
标签: c# xml soap xml-serialization workday-api