locked
Unable to consume SOAP based Web Service which returns the complex type XML. RRS feed

  • Question

  • User-1550809700 posted

    Hello,

    To consume the web service using WSDL , we have created the service reference and are trying to access the web service method as below:

    ServiceReference5.GetPolicyClient customerpolicy = new ServiceReference5.GetPolicyClient();
    ServiceReference5.Customer cust2 = new ServiceReference5.Customer();
    cust2 = customerpolicy.getPolicy(model.PolicyNo).policyOwner;

    However, we are getting the following error when we are trying to run the application.

    Server Error in '/' Application.


    Error in line 1 position 3475. 'EndElement' 'getPolicyReturn' from namespace 'http://services.auto.cf.com' is not expected. Expecting element 'billingAccount'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.Serialization.SerializationException: Error in line 1 position 3475. 'EndElement' 'getPolicyReturn' from namespace 'http://services.auto.cf.com' is not expected. Expecting element 'billingAccount'.

    Source Error:

    Line 1160:        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    Line 1161:        CFTrial.ServiceReference5.getPolicyResponse CFTrial.ServiceReference5.GetPolicy.getPolicy(CFTrial.ServiceReference5.getPolicyRequest request) {
    Line 1162: return base.Channel.getPolicy(request); Line 1163:        }
    Line 1164:        


    Source File: h:\CFTrial_1027_2\CFTrial_1023_1\CFTrial_1022\CFTrial\CFTrial\Service References\ServiceReference5\Reference.cs    Line: 1162

    Stack Trace:

    [SerializationException: Error in line 1 position 3475. 'EndElement' 'getPolicyReturn' from namespace 'http://services.auto.cf.com' is not expected. Expecting element 'billingAccount'.]
       System.Runtime.Serialization.XmlObjectSerializerReadContext.ThrowRequiredMemberMissingException(XmlReaderDelegator xmlReader, Int32 memberIndex, Int32 requiredIndex, XmlDictionaryString[] memberNames) +733894
       ReadPolicyFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] ) +2418
       System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context) +45
       System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader) +16
       System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract) +125
       System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns) +65
       ReadgetPolicyResponseBodyFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] ) +189
       System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context) +45
       System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader) +16
       System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract) +125
       System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns) +46
       System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver) +235
       System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) +86
       System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName) +46
       System.ServiceModel.Dispatcher.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer) +18
       System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest) +45
    
    [NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://services.auto.cf.com:getPolicyResponse. The InnerException message was 'Error in line 1 position 3475. 'EndElement' 'getPolicyReturn' from namespace 'http://services.auto.cf.com' is not expected. Expecting element 'billingAccount'.'.  Please see InnerException for more details.]
       System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10618399
       System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336
       CFTrial.ServiceReference5.GetPolicy.getPolicy(getPolicyRequest request) +0
       CFTrial.ServiceReference5.GetPolicyClient.CFTrial.ServiceReference5.GetPolicy.getPolicy(getPolicyRequest request) in h:\CFTrial_1027_2\CFTrial_1023_1\CFTrial_1022\CFTrial\CFTrial\Service References\ServiceReference5\Reference.cs:1162
       CFTrial.ServiceReference5.GetPolicyClient.getPolicy(String policyNbr) in h:\CFTrial_1027_2\CFTrial_1023_1\CFTrial_1022\CFTrial\CFTrial\Service References\ServiceReference5\Reference.cs:1169
       CFTrial.Controllers.UserController.LoginTrouble(Login model) in h:\CFTrial_1027_2\CFTrial_1023_1\CFTrial_1022\CFTrial\CFTrial\Controllers\UserController.cs:299
       lambda_method(Closure , ControllerBase , Object[] ) +104
       System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
       System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
       System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
       System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
       System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
       System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
       System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
       System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
       System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9628700
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044      



    Any help would be appreciated.


    Thank you,

    Lavi

          

    Monday, October 28, 2013 7:20 PM

All replies

  • User-484054684 posted

    I could see two possible reasons:

    1. Your proxy is not in sync with the service. (i.e., you may need to take the latest wsdl and refresh/regenerate the proxy).

    2. getPolicyResponse object has (refers) some billingAccount object in it. It looks like mandatory element but the service has not returned this billingAccount object in the response.

    Please mark this as answer if this answers your question.

    Tuesday, October 29, 2013 9:12 AM
  • User-1623675128 posted

    I would suggest you use the fiddler and see what is actual XML  that is being sent to server and compare with sample SOAP XML if you have recieved it from server folks.

    Wednesday, October 30, 2013 12:38 AM
  • User-488622176 posted

    Remove the service reference in your project, and add it from scratch. This will refresh your proxy.

    Wednesday, October 30, 2013 8:25 AM
  • User-1550809700 posted

    Thank you Siva.

    I will try all the solutions today.

    Wednesday, October 30, 2013 10:00 AM
  • User-1550809700 posted

    Thank you Illeris.

    Wednesday, October 30, 2013 10:00 AM
  • User-1550809700 posted

    Hello Ramana,

    Thank you for your response.

    We were trying to use the fiddler to track the traffic between the application and the Web Service.  Below are the steps which we followed:

    1) Installed Fiddler and enabled the HTTPS traffice Decryption as given in the fiddler docs.

    http://fiddler2.com/documentation/Configure-Fiddler/Tasks/DecryptHTTPS

    2) Since we do-not have the admin rights,we created the application config file(in our case CFTrial.config) and added the following the lines of code.

    <configuration>
     <system.net>
      <defaultProxy>
       <proxy bypassonlocal="false" usesystemdefault="true" />
      </defaultProxy>
     </system.net>
    </configuration>

    We are still not able to see the traffic between the application and the Web Service. Are we missing something here?

    It will be great if you can help us out.

    Thanks in advance.

    Lavi

    Friday, November 1, 2013 1:00 PM