Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / November 2005

Tip: Looking for answers? Try searching our database.

XML Deserialization

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sujith Jagini - 22 Sep 2005 17:45 GMT
Hi

I am facing this strange problem, we are receiving  xml documents from
Siebel which I am trying to deserialize into class objects for further
processing. The encoding of the document is utf-16 and siebel will post it to
an asp.net page, where I retrieve it as binary and convert it into unicode
formatting. To make sure, I have even commented the utf-8  default setting
defined in app.config and set the response encoding to,  
Page.Response.ContentEncoding = Page.Request.ContentEncoding.

When I try to load the given xml into xmldoc.LoadXml(xmlString), thats where
it fails,  with the following exception: Bottom.

The real goofy is if write the xml into a file and read it back into string,
I am able to load into document xmldoc.LoadXml(xmlString) and also
deserialize the string into class object.

This is running me crazy, though I have a temporary solution for now. Any
thoughs??
--------------------------------------------------
<?xml version="1.0" encoding="UTF-16"?>
<?Siebel-Property-Set EscapeNames="false"?>
<SiebelMessage MessageId="AO-ZHV" IntObjectName="HWAF2 Create Project
nounderscore" MessageType="Integration Object" IntObjectFormat="Siebel
Hierarchical">
    <CREATEPROJECT>
        <SERVICEAGREEMENT>
            <PMPROJECTREFERENCE>1-13ZK2F</PMPROJECTREFERENCE>
            <STARTDATE>09/02/2004 00:00:00</STARTDATE>
            <DESCRIPTION>Service Level Agreement</DESCRIPTION>
            <BILLTOSITENUMBER>1+2SB+3461</BILLTOSITENUMBER>
            <EMPLOYEENUMBERCA>E707995</EMPLOYEENUMBERCA>
            <CreatedByName>CCMARTIN</CreatedByName>
            <EMPLOYEENUMBERFSL>E707995</EMPLOYEENUMBERFSL>
            <ORGANIZATIONNAME/>
            <SentToOracle/>
            <CREATEDFROMTEMPLATENAME>Local</CREATEDFROMTEMPLATENAME>
            <OUTPUTTAXCODE/>
            <PROJECTTYPEATTRIBUTE3/>
            <PROJECTNAME>1-13ZK2F</PROJECTNAME>
            <PROJECTNUMBER/>
            <SHIPTOSITENUMBER>1+2SB+3461</SHIPTOSITENUMBER>
            <AGREEMENTENTITLEMENTLIST>
                <AGREEMENTENTITLEMENT>
                    <TASKREFERENCE>1-13ZK2G</TASKREFERENCE>
                    <TASKSTARTDATE>07/12/2005 00:00:00</TASKSTARTDATE>
                    <TASKNAMEEntName>SR Ticket Information - PM</TASKNAMEEntName>
                    <SERVICETYPECODEPlatform/>
                    <TASKNAMEPlatform/>
                    <SERVICETYPECODESrvPgm/>
                    <TASKNAMESrvcPgm/>
                    <SERVICETYPECODEName>SR Ticket Information - PM</SERVICETYPECODEName>
                    <TASKNUMBER>111-1111</TASKNUMBER>
                </AGREEMENTENTITLEMENT>
            </AGREEMENTENTITLEMENTLIST>
        </SERVICEAGREEMENT>
    </CREATEPROJECT>
</SiebelMessage>
----------------------------------------------------
System.Xml.XmlException: The data at the root level is invalid. Line 1,
position 1.
  at System.Xml.XmlTextReader.ParseRoot()
  at System.Xml.XmlTextReader.Read()
  at System.Xml.XmlValidatingReader.ReadWithCollectTextToken()
  at System.Xml.XmlValidatingReader.Read()
  at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace)
  at System.Xml.XmlDocument.Load(XmlReader reader)
  at System.Xml.XmlDocument.LoadXml(String xml)
  at Honeywell.EMEA.Integration.Main.MapAndExecute(String xml, String path)
in
c:\sujith\honeywell\dotnet\honeywell.emea1\honeywell.emea.integration\main.cs:line 50
  at SiebelRequests.WebForm2.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\SiebelRequests\WebForm2.aspx.vb:line 205

----------------------------------------------------------------------------
Note: I tried with utf-8, where Siebel sends utf-8, modifed the asp.net'
web.config to utf-8, and binary stream into utf-8 , it fails again.
-----------------------------------------------------------------------------

Thanks
Derek Harmon - 23 Sep 2005 00:33 GMT
> processing. The encoding of the document is utf-16 and siebel will post it to
> an asp.net page, where I retrieve it as binary and convert it into unicode
: :
> System.Xml.XmlException: The data at the root level is invalid. Line 1,
> position 1.
>   at System.Xml.XmlTextReader.ParseRoot()

This happens when the bits you're feeding XmlDocument are not UTF-16 (or
are otherwise mismatched to what the XmlDecl encoding in the document is
saying.)

> This is running me crazy, though I have a temporary solution for now. Any
> thoughs??
: :
> <?xml version="1.0" encoding="UTF-16"?>

Try removing the segment, "encoding="UTF-16", and see if XmlTextReader
finds this more appetizing.

> <SiebelMessage MessageId="AO-ZHV" IntObjectName="HWAF2 Create Project
> nounderscore" MessageType="Integration Object" IntObjectFormat="Siebel
> Hierarchical">

XML appears mostly OK, assuming it's claim of being UTF-16 encoded is
still true.

If I cut this text out of your message and save it into a Unicode text file, and
then load it into a string, and test it ... it'll work.<g>   What is actually needed
to repro your problem would be the binary rep of the encoded text.

Derek Harmon
fausto - 24 Nov 2005 16:58 GMT
Hello Sujith, I am fausto.

At the moment i'm trying developing a web service that execute
a siebel workflow.

i am received this one message "Cast is not valid"

This is the code:

Thanks a lot in advance

fausto

Public Function GenerarPedido(ByVal sCodCrm As String) As String
       Dim SiebelApplication As SiebelDataServer.SiebelApplication
       ' Dim BusObj As SiebelBusObject
       ' Dim BusComp As SiebelBusComp
       Dim errcode As Short
       Dim ErrText As String
       Dim objBS As SiebelDataServer.SiebelService
       Dim Inputs As SiebelDataServer.SiebelPropertySet
       Dim Outputs As SiebelDataServer.SiebelPropertySet
       Dim sResp As String

       Try
           ChDrive("D")
           ChDir("d:\sea\sceesn\bin")
           SiebelApplication =
CreateObject("SiebelDataServer.ApplicationObject")

           With SiebelApplication

               .LoadObjects("d:\sea\sceesn\bin\PECDesarrollo.cfg", errcode)

               If errcode <> 0 Then
                   ErrText = .GetLastErrText
                   Return ErrText.ToString()
                   Exit Function
               End If
               .Login("gvergard", "cambiame", errcode)
               If errcode <> 0 Then
                   ErrText = .GetLastErrText
                   Return ErrText.ToString()
                   Exit Function
               End If
           End With

           '** Here failed ****
           objBS = SiebelApplication.GetService("Workflow Process Manager",
errcode)
           '***
           Inputs = SiebelApplication.NewPropertySet(errcode)

           '1-AL9RT
           Outputs = SiebelApplication.NewPropertySet(errcode)
           Inputs.SetProperty("Object Id", sCodCrm, errcode)
           Inputs.SetProperty("ProcessName", "PECWFPIntegracionGetPedido",
errcode) 'este es el workflow que ejecuta

           'Invocar el metodo, entregandole el nombre del metodo y los Pset
de entrada y salida
           objBS.InvokeMethod("RunProcess", Inputs, Outputs, errcode)
           sResp = Outputs.GetProperty("String XML", errcode)

           If errcode <> 0 Then
               ErrText = SiebelApplication.GetLastErrText()
               Return ErrText.ToString()
               Exit Function
           End If

           objBS = Nothing
           SiebelApplication = Nothing
           Inputs = Nothing
           Outputs = Nothing
       Catch ex As Exception
           Return ex.Message.ToString
       End Try

   End Function

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.