格式化程序在尝试反序列化消息时抛出异常:

时间:2012-03-21 11:15:29

标签: web-services soapui

我从客户那里得到了一个wsdl来消费。我正在使用soupUI工具。我得到了像

这样的请求xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vmps="http://dynamicops.com/VMPS" xmlns:dyn="http://DynamicOps.VMPS.Model" xmlns:dyn1="http://schemas.datacontract.org/2004/07/DynamicOps.VMPS.Model" xmlns:dyn2="http://DynamicOps.Common.BaseModel">
   <soapenv:Header/>
   <soapenv:Body>
      <vmps:CreateVirtualMachineTemplate>
         <!--Optional:-->
         <vmps:identityToken>
            <!--Optional:-->
            <dyn:ImpersonatingUser>?</dyn:ImpersonatingUser>
            <!--Optional:-->
            <dyn:User>?</dyn:User>
         </vmps:identityToken>
         <!--Optional:-->
         <vmps:template>
            <!--Optional:-->
            <dyn1:ID>?</dyn1:ID>
            <!--Optional:-->
            <dyn2:Name>?</dyn2:Name>
            <!--Optional:-->
            <dyn2:Description>?</dyn2:Description>
            <!--Optional:-->
            <dyn:ApprovalPolicyId>?</dyn:ApprovalPolicyId>
            <!--Optional:-->
            <dyn:BlueprintType>?</dyn:BlueprintType>
            <!--Optional:-->
            <dyn:Cost>?</dyn:Cost>
            <!--Optional:-->
            <dyn:CpuCount>?</dyn:CpuCount>
            <!--Optional:-->
            <dyn:CpuCountMax>?</dyn:CpuCountMax>
            <!--Optional:-->
            <dyn:CreatedAt>?</dyn:CreatedAt>
            <!--Optional:-->
            <dyn:DeletedAt>?</dyn:DeletedAt>
            <!--Optional:-->
            <dyn:DiskSize0InGB>?</dyn:DiskSize0InGB>
            <!--Optional:-->
            <dyn:DiskSizeMaxGB>?</dyn:DiskSizeMaxGB>
            <!--Optional:-->
            <dyn:Enabled>?</dyn:Enabled>
            <!--Optional:-->
            <dyn:ExpireDays>?</dyn:ExpireDays>
            <!--Optional:-->
            <dyn:GlobalProfileID>?</dyn:GlobalProfileID>
            <!--Optional:-->
            <dyn:Groups>
               <!--Zero or more repetitions:-->
               <dyn:GroupBase>
                  <!--Optional:-->
                  <dyn1:ID>?</dyn1:ID>
                  <!--Optional:-->
                  <dyn2:Name>?</dyn2:Name>
                  <!--Optional:-->
                  <dyn2:Description>?</dyn2:Description>
                  <!--Optional:-->
                  <dyn:AdministratorEmail>?</dyn:AdministratorEmail>
                  <!--Optional:-->
                  <dyn:GroupID>?</dyn:GroupID>
                  <!--Optional:-->
                  <dyn:IsTestGroup>?</dyn:IsTestGroup>
               </dyn:GroupBase>
            </dyn:Groups>
            <!--Optional:-->
            <dyn:IsGlobal>?</dyn:IsGlobal>
            <!--Optional:-->
            <dyn:IsMaster>?</dyn:IsMaster>
            <!--Optional:-->
            <dyn:LeaseDays>?</dyn:LeaseDays>
            <!--Optional:-->
            <dyn:LeaseDaysMax>?</dyn:LeaseDaysMax>
            <!--Optional:-->
            <dyn:MachinePrefix>?</dyn:MachinePrefix>
            <!--Optional:-->
            <dyn:MachineType>?</dyn:MachineType>
            <!--Optional:-->
            <dyn:MaxVMsPerUser>?</dyn:MaxVMsPerUser>
            <!--Optional:-->
            <dyn:Members>?</dyn:Members>
            <!--Optional:-->
            <dyn:MemoryInMB>?</dyn:MemoryInMB>
            <!--Optional:-->
            <dyn:MemoryMaxMB>?</dyn:MemoryMaxMB>
            <!--Optional:-->
            <dyn:ParentID>?</dyn:ParentID>
            <!--Optional:-->
            <dyn:RequiresApproval>?</dyn:RequiresApproval>
            <!--Optional:-->
            <dyn:ReservationPolicyID>?</dyn:ReservationPolicyID>
            <!--Optional:-->
            <dyn:UpdatedAt>?</dyn:UpdatedAt>
            <!--Optional:-->
            <dyn:WorkflowID>?</dyn:WorkflowID>
            <!--Optional:-->
            <dyn:WorkflowInfo>
               <!--Optional:-->
               <dyn1:ID>?</dyn1:ID>
               <!--Optional:-->
               <dyn2:Name>?</dyn2:Name>
               <!--Optional:-->
               <dyn2:Description>?</dyn2:Description>
               <!--Optional:-->
               <dyn:AssemblyFQN>?</dyn:AssemblyFQN>
               <!--Optional:-->
               <dyn:BuildTagType>?</dyn:BuildTagType>
            </dyn:WorkflowInfo>
            <!--Optional:-->
            <dyn:HiddenProperties>
               <!--Zero or more repetitions:-->
               <dyn:NameValue>
                  <!--Optional:-->
                  <dyn:IsEncrypted>?</dyn:IsEncrypted>
                  <!--Optional:-->
                  <dyn:IsHidden>?</dyn:IsHidden>
                  <!--Optional:-->
                  <dyn:IsRuntime>?</dyn:IsRuntime>
                  <!--Optional:-->
                  <dyn:Name>?</dyn:Name>
                  <!--Optional:-->
                  <dyn:Value>?</dyn:Value>
               </dyn:NameValue>
            </dyn:HiddenProperties>
            <!--Optional:-->
            <dyn:LeaseCostFormatted>?</dyn:LeaseCostFormatted>
            <!--Optional:-->
            <dyn:Parent>
               <!--Optional:-->
               <dyn1:ID>?</dyn1:ID>
               <!--Optional:-->
               <dyn2:Name>?</dyn2:Name>
               <!--Optional:-->
               <dyn2:Description>?</dyn2:Description>
               <!--Optional:-->
               <dyn:ApprovalPolicyId>?</dyn:ApprovalPolicyId>
               <!--Optional:-->
               <dyn:BlueprintType>?</dyn:BlueprintType>
               <!--Optional:-->
               <dyn:Cost>?</dyn:Cost>
               <!--Optional:-->
               <dyn:CpuCount>?</dyn:CpuCount>
               <!--Optional:-->
               <dyn:CpuCountMax>?</dyn:CpuCountMax>
               <!--Optional:-->
               <dyn:CreatedAt>?</dyn:CreatedAt>
               <!--Optional:-->
               <dyn:DeletedAt>?</dyn:DeletedAt>
               <!--Optional:-->
               <dyn:DiskSize0InGB>?</dyn:DiskSize0InGB>
               <!--Optional:-->
               <dyn:DiskSizeMaxGB>?</dyn:DiskSizeMaxGB>
               <!--Optional:-->
               <dyn:Enabled>?</dyn:Enabled>
               <!--Optional:-->
               <dyn:ExpireDays>?</dyn:ExpireDays>
               <!--Optional:-->
               <dyn:GlobalProfileID>?</dyn:GlobalProfileID>
               <!--Optional:-->
               <dyn:Groups>
                  <!--Zero or more repetitions:-->
                  <dyn:GroupBase>
                     <!--Optional:-->
                     <dyn1:ID>?</dyn1:ID>
                     <!--Optional:-->
                     <dyn2:Name>?</dyn2:Name>
                     <!--Optional:-->
                     <dyn2:Description>?</dyn2:Description>
                     <!--Optional:-->
                     <dyn:AdministratorEmail>?</dyn:AdministratorEmail>
                     <!--Optional:-->
                     <dyn:GroupID>?</dyn:GroupID>
                     <!--Optional:-->
                     <dyn:IsTestGroup>?</dyn:IsTestGroup>
                  </dyn:GroupBase>
               </dyn:Groups>
               <!--Optional:-->
               <dyn:IsGlobal>?</dyn:IsGlobal>
               <!--Optional:-->
               <dyn:IsMaster>?</dyn:IsMaster>
               <!--Optional:-->
               <dyn:LeaseDays>?</dyn:LeaseDays>
               <!--Optional:-->
               <dyn:LeaseDaysMax>?</dyn:LeaseDaysMax>
               <!--Optional:-->
               <dyn:MachinePrefix>?</dyn:MachinePrefix>
               <!--Optional:-->
               <dyn:MachineType>?</dyn:MachineType>
               <!--Optional:-->
               <dyn:MaxVMsPerUser>?</dyn:MaxVMsPerUser>
               <!--Optional:-->
               <dyn:Members>?</dyn:Members>
               <!--Optional:-->
               <dyn:MemoryInMB>?</dyn:MemoryInMB>
               <!--Optional:-->
               <dyn:MemoryMaxMB>?</dyn:MemoryMaxMB>
               <!--Optional:-->
               <dyn:ParentID>?</dyn:ParentID>
               <!--Optional:-->
               <dyn:RequiresApproval>?</dyn:RequiresApproval>
               <!--Optional:-->
               <dyn:ReservationPolicyID>?</dyn:ReservationPolicyID>
               <!--Optional:-->
               <dyn:UpdatedAt>?</dyn:UpdatedAt>
               <!--Optional:-->
               <dyn:WorkflowID>?</dyn:WorkflowID>
               <!--Optional:-->
               <dyn:WorkflowInfo>
                  <!--Optional:-->
                  <dyn1:ID>?</dyn1:ID>
                  <!--Optional:-->
                  <dyn2:Name>?</dyn2:Name>
                  <!--Optional:-->
                  <dyn2:Description>?</dyn2:Description>
                  <!--Optional:-->
                  <dyn:AssemblyFQN>?</dyn:AssemblyFQN>
                  <!--Optional:-->
                  <dyn:BuildTagType>?</dyn:BuildTagType>
               </dyn:WorkflowInfo>
            </dyn:Parent>
            <!--Optional:-->
            <dyn:Properties>
               <!--Zero or more repetitions:-->
               <dyn:NameValue>
                  <!--Optional:-->
                  <dyn:IsEncrypted>?</dyn:IsEncrypted>
                  <!--Optional:-->
                  <dyn:IsHidden>?</dyn:IsHidden>
                  <!--Optional:-->
                  <dyn:IsRuntime>?</dyn:IsRuntime>
                  <!--Optional:-->
                  <dyn:Name>?</dyn:Name>
                  <!--Optional:-->
                  <dyn:Value>?</dyn:Value>
               </dyn:NameValue>
            </dyn:Properties>
         </vmps:template>
      </vmps:CreateVirtualMachineTemplate>
   </soapenv:Body>
</soapenv:Envelope>

当我发送此请求时,我收到的响应如

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <s:Fault>
         <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
         <faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://dynamicops.com/VMPS:template. The InnerException message was 'There was an error deserializing the object of type DynamicOps.VMPS.Model.VirtualMachineTemplateEx. The value '?' cannot be parsed as the type 'Guid'.'.  Please see InnerException for more details.</faultstring>
         <detail>
            <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
               <HelpLink i:nil="true"/>
               <InnerException>
                  <HelpLink i:nil="true"/>
                  <InnerException>
                     <HelpLink i:nil="true"/>
                     <InnerException>
                        <HelpLink i:nil="true"/>
                        <InnerException i:nil="true"/>
                        <Message>Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).</Message>
                        <StackTrace>at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
   at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult&amp; result)
   at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult&amp; result)
   at System.Guid.Parse(String input)
   at System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsGuid()</StackTrace>
                        <Type>System.FormatException</Type>
                     </InnerException>
                     <Message>The value '?' cannot be parsed as the type 'Guid'.</Message>
                     <StackTrace>at System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsGuid()
   at ReadVirtualMachineTemplateExFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)</StackTrace>
                     <Type>System.Xml.XmlException</Type>
                  </InnerException>
                  <Message>There was an error deserializing the object of type DynamicOps.VMPS.Model.VirtualMachineTemplateEx. The value '?' cannot be parsed as the type 'Guid'.</Message>
                  <StackTrace>at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)</StackTrace>
                  <Type>System.Runtime.Serialization.SerializationException</Type>
               </InnerException>
               <Message>The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://dynamicops.com/VMPS:template. The InnerException message was 'There was an error deserializing the object of type DynamicOps.VMPS.Model.VirtualMachineTemplateEx. The value '?' cannot be parsed as the type 'Guid'.'.  Please see InnerException for more details.</Message>
               <StackTrace>at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
               <Type>System.ServiceModel.Dispatcher.NetDispatcherFaultException</Type>
            </ExceptionDetail>
         </detail>
      </s:Fault>
   </s:Body>
</s:Envelope>

任何人都可以帮我解决问题吗? 在此先感谢。

1 个答案:

答案 0 :(得分:2)

您必须使用值填充您的请求,其中现在标有“?”。错误消息表明GUID类型的字段包含无效值,并且因为您的请求都是“?”没有有效的GUID。用合适的价值填写你的请求,问题应该消失。

提及问号语法的教程是here