none
WCF Request does not match what is expecting by Service when the request is created in BizTalk Map RRS feed

  • Question

  • I have a WCF Service that I’m consuming and it has its contract defined.  I consume the service in BizTalk and get the proper schemas and build the port.  I map a request to the request schema of the WCF Service to ensure the contract is properly fulfilled and send off the request.  I get rejected because the contract is not what was expected.  So.  I use fiddler and send a good request from a WCF Client, capture the payload and compare it to the payload that is generated by biztalk.  Here is what we have:

    Good Request:
    <Find xmlns="http://tempuri.org/">
                <query xmlns:a="http://schemas.datacontract.org/2004/07/RJ.ODS.Balances.Model" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                            <a:Includes i:nil="true" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
                            <a:Parameters xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                                        <b:KeyValueOfstringanyType>
                                                    <b:Key>AccNo</b:Key>
                                                    <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">1000xxxx</b:Value>
                                        </b:KeyValueOfstringanyType>
                            </a:Parameters>
                            <a:QueryString>SELECT VALUE acct &#xD;
                        FROM AccountArrangements AS acct &#xD;
                        WHERE acct.AccountNumber = @AccNo</a:QueryString>
                </query>
    </Find>

    Bad Request
    <ns0:Find xmlns:ns0="http://tempuri.org/" xmlns:ns2="http://schemas.datacontract.org/2004/07/RJ.ODS.Balances.Model" xmlns:ns1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                <ns0:query>
                            <ns2:Parameters>
                                        <ns1:KeyValueOfstringanyType>
                                                    <ns1:Key>AccNo</ns1:Key>
                                                    <ns1:Value>1000xxxx</ns1:Value>
                                        </ns1:KeyValueOfstringanyType>
                            </ns2:Parameters>
                            <ns2:QueryString>SELECT VALUE acct FROM AccountArrangements AS acct WHERE acct.AccountNumber = @AccNo</ns2:QueryString>
                </ns0:query>
    </ns0:Find>

    Here is the Exception

    <?xml version="1.0" encoding="UTF-8"?>
    <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://tempuri.org/:query. The InnerException message was 'Element Value from namespace http://schemas.microsoft.com/2003/10/Serialization/Arrays cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.'.  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 i:nil="true"/>
                                                                                        <Message>End element 'Value' from namespace 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' expected. Found text '10002169'. Line 1, position 358.</Message>
                                                                                        <StackTrace>   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)&#xD;   at System.Xml.XmlBaseReader.ReadEndElement()&#xD;   at System.Runtime.Serialization.ObjectDataContract.ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)</StackTrace>
                                                                                        <Type>System.Xml.XmlException</Type>
                                                                            </InnerException>
                                                                            <Message>Element Value from namespace http://schemas.microsoft.com/2003/10/Serialization/Arrays cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.</Message>
                                                                            <StackTrace>   at System.Runtime.Serialization.ObjectDataContract.ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)&#xD;   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)&#xD;   at ReadKeyValueOfstringanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )&#xD;   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)&#xD;   at ReadArrayOfKeyValueOfstringanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )&#xD;   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)&#xD;   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)&#xD;   at ReadObjectQueryFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )&#xD;   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)&#xD;   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)&#xD;   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;   at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)&#xD;   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://tempuri.org/:query. The InnerException message was 'Element Value from namespace http://schemas.microsoft.com/2003/10/Serialization/Arrays cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.'.  Please see InnerException for more details.</Message>
                                                                <StackTrace>   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)&#xD;   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)&#xD;   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)&#xD;   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)&#xD;   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)&#xD;   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)&#xD;   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)&#xD;   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
                                                                <Type>System.ServiceModel.Dispatcher.NetDispatcherFaultException</Type>
                                                    </ExceptionDetail>
                                        </detail>
                            </s:Fault>
                </s:Body>
    </s:Envelope>

     

    It would appear that simply placing the sting type in the request would solve this issue, however, how on earth do I override what the mapper creates without writing custom code.  The contract is the contract and should be represented in the WSDL and the result of the mapper should build that out….    Any thoughts, anyone??

    H

     

    Saturday, October 29, 2011 5:05 PM

All replies

  • Can you post the request contract from the wsdl, I mean the schema is the issue here. You are missing the following too in the bad request are you mapping that in the map.

    <a:Includes i:nil="true" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
    



    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Sunday, October 30, 2011 6:44 AM