Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 生成XML文档时出错-Workday WebAPI_C#_Xml_Soap_Xml Serialization_Workday Api - Fatal编程技术网

C# 生成XML文档时出错-Workday WebAPI

C# 生成XML文档时出错-Workday WebAPI,c#,xml,soap,xml-serialization,workday-api,C#,Xml,Soap,Xml Serialization,Workday Api,调用时,突然出现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

调用时,突然出现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_WorkTagObjectId类型在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 { ... }
//
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.Xml”,“4.7.2612.0”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
[System.Xml.Serialization.XmlTypeAttribute(Namespace=“urn:com.workday/bsvc”)]
公共部分类租用\u Payroll\u worktagObjectedType:对象,System.ComponentModel.INotifyPropertyChanged{…}

如何调试这个?我能做些什么来让它工作

从WSDL生成的References.cs中出现错误,列出了不正确的类型Tenanted\u Payroll\u WorktagObjectType,而不是Tenanted\u Payroll\u WorkTagObjectId类型,其中需要Tenanted\u Payroll\u WorkTagObjectId类型。手动更改自动生成的文件修复了该问题

我想代码是有效的。我怀疑代理有问题。证书的日期可能已过期。检查一下你的证书,看看是否有过期的。如果您使用IE访问站点,URL是否有效?@jdweng出错的对象实际上是正在序列化的较大对象的一部分。更正了问题。不,它在这种配置下不工作。如果我删除被租用的\u Payroll\u worktagObjectedType实例,一切都会正常工作。代码看起来像是收到了代理错误。我会使用wireshark或fiddler之类的嗅探器来查看应用程序是否正在尝试与代理服务器通信。您将看到一个请求被发送到一个代理,但没有响应,这表明代理没有运行(或者可能您使用了错误的ip),或者您将收到一个响应,然后可能该响应将表明错误的真正根源。它不接近通信部分。将有效负载对象转换为XML时出错。在创建传出消息之前,请求失败。如果未首先连接到代理服务器以从代理服务器获取密钥,则无法创建xml。这就是异常消息所说的。soapxml包含一个加密部分,这是发生故障的地方。我不知道是连接错误还是你电脑上的证书过期了。