Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Below is my stub classes generated by wsdl.exe

C#
[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute("entries", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
public partial mapEntry[] args {
    get {
        return this.argsField;
    }
    set {
        this.argsField = value;
    }
}


Second Class

C#
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservice.api.cabaret.com/")]
public partial class callArgs {

    private string nameField;

    private mapEntry[] argsField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string name {
        get {
            return this.nameField;
        }
        set {
            this.nameField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlArrayItemAttribute("entries", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public mapEntry[] args {
        get {
            return this.argsField;
        }
        set {
            this.argsField = value;
        }
    }
}

Below is my response SOAP XML

<pre lang="XML">

<name>signatures</name>
<value xsi:type="ns2:map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<entries><value xsi:type="ns2:map">
<entries>
<name>type</name>
<value xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">signature</value>
</entries>
<entries>
<name>state</name>
<value xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">3</value>
</entries>


During this process I got the " was not expected. error. How I resolved this error? Where I am doing wrong in it? Please help me to resolve this error.

What I have tried:

Below I tried to Deserialize the SOAP XML to Object

C#
XmlRootAttribute xRoot = new XmlRootAttribute("callArgs");
            xRoot.ElementName = "name";
            xRoot.Namespace = "http://webservice.api.cabaret.com/";
            xRoot.IsNullable = true;
            System.IO.StringReader stringReader = new System.IO.StringReader(ValidatePDF[5].InnerXml);
            XmlSerializer deserializer = new XmlSerializer(typeof(callArgs),xRoot);
            callArgs devicesResult = (callArgs)deserializer.Deserialize(stringReader);
Posted
Updated 6-Apr-16 5:50am
v3
Comments
Richard Deeming 6-Apr-16 11:41am    
Don't paraphrase the exception; post the full details of the exception, including any inner exceptions. Remember to indicate which line of code the exception was thrown from.
Sergey Alexandrovich Kryukov 6-Apr-16 12:03pm    
Good point.
Here, it looks like SOAP format is never used. Please see my answer.
—SA
SURAJ-CDAC 7-Apr-16 6:10am    
Exception On this line :- callArgs devicesResult = (callArgs)deserializer.Deserialize(stringReader);

Inner Exception :- {"<name xmlns=""> was not expected."}
StackStrace :-
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
at PDFFieldReader.Form1.CallSeriviceUsingProxy() in C:\Users\patilsur\Desktop\PDFFieldReader\Form1.cs:line 301
at PDFFieldReader.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\patilsur\Desktop\PDFFieldReader\Form1.cs:line 142
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at PDFFieldReader.Program.Main() in C:\Users\patilsur\Desktop\PDFFieldReader\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

1 solution

Well, XmlSerializer is itself pretty bad and outdated, not fun to deal with (compared, say, to data contract based serialization). But with SOAP you have no choice but playing by SOAP rules, even though they are quite bad. And I don't see where you do it. In particular, I cannot see where you use SoapFormatter class:
SoapFormatter Class (System.Runtime.Serialization.Formatters.Soap)[^].

See also:
.NET Serialization using Soap Formatter [^],
XML and SOAP Serialization[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900