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 / ASP.NET / Web Services / March 2005

Tip: Looking for answers? Try searching our database.

Error in XML document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mjf - 15 Feb 2005 00:45 GMT
I'm consuming a web service produced by a Java, non-Microsoft system.
The response will have two complex elements.  One of those has an array
of items.  Before I get back to my code, the system gets an exception:
Error in XML document at (2, 1010).

The exception object shows the following stack string:

    _stackTraceString
  at System.Number.ParseUInt32(String s, NumberStyles style,
NumberFormatInfo info)
  at System.UInt16.Parse(String s, NumberStyles style, IFormatProvider
provider)
  at System.Xml.XmlConvert.ToUInt16(String s)
  at System.Xml.Serialization.XmlCustomFormatter.ToChar(String value)
  at System.Xml.Serialization.XmlSerializationReader.ToChar(String
value)
  at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_FindPurchaseOrderItemSetDTO(Boolean

isNullable, Boolean checkType)
  at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_FindPurchaseOrderItemSetsDTO(Boolean

isNullable, Boolean checkType)
  at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read17_findPurchaseOrderItemSetsResponse()

The internal error in the exception object said something like (I'm
typing from memory), "Invalid format in string.)

1.  Any way I can get hold of the XML document that it's complaining
about?

2.  Any ideas what's causing the error?  (I know; I'm not giving you
much to go on; sorry.)

Thanks.

Michael
Keenan Newton - 15 Feb 2005 03:28 GMT
It maybe the WSDL that the Java bqased web service creates does not
match the actual output.  So when you web service proxy class calls the
java web service the returned result is different from what is
expected.  Can you copy and paste the wsdl to this posting, as well as
the SOAP message itself.
mjf - 15 Feb 2005 18:57 GMT
Keenan; thanks for the reply. I've determined that the problem is in
the conversion to a standard (that is, from
xsd:xml.apache.org/xml-soap) dateTime variable. I can catch the
exception, but it doesn't look like it tells me what the allegedly
offending string is, nor what the dateTime format strings it's trying
to use are.

Also, I don't know how to get hold of the XML string being sent back
from the service. How do I get the entire SOAP message? I'm within the
VSS debugger, but the routines on the stack at the time of the
exception (assuming I don't catch it) don't have source associated with
them, so it's unclear to me how I can get hold of the SOAP message.
Ideas?

The dateTime portion of the WSDL is simply (!):
<xsd:element name="badVar"" nillable="true" type="xsd:dateTime"/>,
where xsd is as above.

Thanks.
mjf - 15 Feb 2005 21:34 GMT
Here's the response that causes the problem (I got it by using a
separate tool).  All of the elements with 'date' in their name are
declared as 'standard' dateTime types, and are allowed to be nil.  The
C# .NET proxy class declares the dateTime variables as System.DateTime.
I don't know why I get a dateTime format error from this document.
Any ideas?  Thanks.

<?xml version="1.0" encoding="UTF-8" ?>
 <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
 <findByReportNumberResponse
xmlns="http://discrepancyreporting.service.yyy.zzz.xxx.com">
 <findByReportNumberReturn>
 <closedBy xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <closedDate xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <closedReference xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <creditDate
xmlns="http://dto.zzz.xxx.com">2005-02-07T14:00:00.000Z</creditDate>
 <creditedBy xmlns="http://dto.zzz.xxx.com">0000000054</creditedBy>
 <creditReference
xmlns="http://dto.zzz.xxx.com">LARRYC</creditReference>
 <creditReplace xmlns="http://dto.zzz.xxx.com">C</creditReplace>
 <creditValue xmlns="http://dto.zzz.xxx.com">1.00</creditValue>
 <discrepancy xmlns="http://dto.zzz.xxx.com">1 MISSING</discrepancy>
 <discrepancyReference
xmlns="http://dto.zzz.xxx.com">1MISS</discrepancyReference>
 <discrepancyReportItemNumber
xmlns="http://dto.zzz.xxx.com">1</discrepancyReportItemNumber>
 <discrepancyReportNumber
xmlns="http://dto.zzz.xxx.com">1</discrepancyReportNumber>
 <discrepancyType1 xmlns="http://dto.zzz.xxx.com" />
 <holdPayment xmlns="http://dto.zzz.xxx.com">Y</holdPayment>
 <medium xmlns="http://dto.zzz.xxx.com">P</medium>
 <purchaseOrderItemNumber
xmlns="http://dto.zzz.xxx.com">1</purchaseOrderItemNumber>
 <purchaseOrderNumber
xmlns="http://dto.zzz.xxx.com">P00015</purchaseOrderNumber>
 <purchaseRequisitionNumber xsi:nil="true"
xmlns="http://dto.zzz.xxx.com" />
 <qualityInspectionCode xmlns="http://dto.zzz.xxx.com" />
 <quantityRequired
xmlns="http://dto.zzz.xxx.com">18.00</quantityRequired>
 <raisedBy xmlns="http://dto.zzz.xxx.com">0000000054</raisedBy>
 <raisedDate
xmlns="http://dto.zzz.xxx.com">2005-02-07T14:00:00.000Z</raisedDate>
 <replacedBy xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <replacementDate xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <replacementQuantity xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />

 <replacementReference xsi:nil="true" xmlns="http://dto.zzz.xxx.com"
/>
 <shipmentCarrier
xmlns="http://dto.zzz.xxx.com">FEDEX</shipmentCarrier>
 <shipmentDate
xmlns="http://dto.zzz.xxx.com">2005-02-07T14:00:00.000Z</shipmentDate>
 <shipmentInsurance
xmlns="http://dto.zzz.xxx.com">NONE</shipmentInsurance>
 <shipmentPaymentType
xmlns="http://dto.zzz.xxx.com">P</shipmentPaymentType>
 <shipmentReference
xmlns="http://dto.zzz.xxx.com">LARRYC</shipmentReference>
 <stockCode xmlns="http://dto.zzz.xxx.com">000001446</stockCode>
 <supplierContact
xmlns="http://dto.zzz.xxx.com">CHARLIE</supplierContact>
 <supplierContacted
xmlns="http://dto.zzz.xxx.com">Y</supplierContacted>
 <supplierNumber
xmlns="http://dto.zzz.xxx.com">000006</supplierNumber>
 <unitOfMeasure xmlns="http://dto.zzz.xxx.com">EA</unitOfMeasure>
 <updateStatistics xmlns="http://dto.zzz.xxx.com" />
 <waybillItemNumber xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <waybillNumber xsi:nil="true" xmlns="http://dto.zzz.xxx.com" />
 <discrepancyReportStatus
xmlns="http://dto.zzz.xxx.com">OPEN</discrepancyReportStatus>
 <discrepancyQuantity
xmlns="http://dto.zzz.xxx.com">1</discrepancyQuantity>
 </findByReportNumberReturn>
 </findByReportNumberResponse>
 </soapenv:Body>
 </soapenv:Envelope>

> Keenan; thanks for the reply. I've determined that the problem is in
> the conversion to a standard (that is, from
[quoted text clipped - 15 lines]
>
> Thanks.
Keenan Newton - 15 Feb 2005 23:41 GMT
I don't beleive System.Datetime allows for null values in .Net
Michael Flanagan - 16 Feb 2005 03:12 GMT
> I don't beleive System.Datetime allows for null values in .Net

Keenan, Is there any way I can confirm that?  I had the service provider
send a response with all DateTime fields non-nil, and still got the same
error.  Any ideas?

Also, do you know how I can get hold of the SOAP/XML document that
constitutes the response?

Thanks.  Michael
mflanagan@RemoveThis.MJFlanagan.com - 16 Feb 2005 03:40 GMT
>> I don't beleive System.Datetime allows for null values in .Net
>
[quoted text clipped - 6 lines]
>
>Thanks.  Michael

Now that I'm re-reading it, my question doesn't make a lot of sense.
I confirmed what you said as far as the System.DateTime object.
That's not necessarily the same as saying that the XML parser won't
check the 'nil' attribute and set the DateTime proxy variable to some
initial value.  So what I meant to ask is how I can confirm that a
DateTime variable in a web service response cannot have the nil="true"
attribute?
Keenan Newton - 16 Feb 2005 03:59 GMT
Well i am sure the SOAP Response can have nil=true, but if I am correct
when .Net trys to read it, and find it null.  It may not know how to
handle it.  Now I am just going to recommend some debuggin techniques.
I am assuming you have control over the Java web service.  or you can
create your own.  I would create a simple service that would return
dummy data for all the parametes you need.  Then i would remove all of
the parameters but one, and slowly add each one in until it breaks.
Again the Date time looks ok.
mjf - 16 Feb 2005 16:51 GMT
> Well i am sure the SOAP Response can have nil=true, but if I am correct
> when .Net trys to read it, and find it null.  It may not know how to
[quoted text clipped - 4 lines]
> the parameters but one, and slowly add each one in until it breaks.
> Again the Date time looks ok.

Keenan, thanks again.  Here is a link that others have pointed me to.
It seems that .NET won't deserialize nil DateTimes (as you suspected!).
I don't really have control of the web service, so I'm scrambling.

Thanks again.

Michael

Look here: http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx
mjf - 18 Feb 2005 17:01 GMT
> > Well i am sure the SOAP Response can have nil=true, but if I am
> correct
[quoted text clipped - 17 lines]
>
> Look here: http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx

One additional comment: I found a way to get at the XML that .NET is
trying to parse.  One only (!) need write a Soap Extension (in
System.Web.Services.Protocols), and you can see the outgoing and
incoming messages.  I'm surprised nobody suggested this.  (Okay, not
very surprised.)
ags - 21 Feb 2005 23:07 GMT
Hello,
Can you put the example you wrote for the SoapExtension ?
Thanks !

> > > Well i am sure the SOAP Response can have nil=true, but if I am
> > correct
[quoted text clipped - 27 lines]
> incoming messages.  I'm surprised nobody suggested this.  (Okay, not
> very surprised.)
mflanagan@RemoveThis.MJFlanagan.com - 22 Feb 2005 02:49 GMT
>Hello,
>Can you put the example you wrote for the SoapExtension ?
[quoted text clipped - 5 lines]
>> incoming messages.  I'm surprised nobody suggested this.  (Okay, not
>> very surprised.)

I pulled it out of ".NET Web Services" by O'Reilly, so I'm not sure I
can post it due to copyright issues.  Perhaps it's on the O'Reilly
site for the book.  Otherwise, I'd love to.  Sorry.

Michael
Softwaremaker - 01 Mar 2005 22:19 GMT
To do what Keenan suggested here, you may want to take a look at this tool
to help you:
http://www.softwaremaker.net/blog/PermaLink,guid,7deab38b-92af-446b-b7d8-6aa9010
07130.aspx


It lets you manually craft out the exact message you want faster to post and
it gives you exactly the SOAP Faults thrown. In this case, you dont have to
compile and run the client all the time. Once you can get the message you
want, then you can manipulate the XMLSerializer to do exactly what you want.

Signature

Thank you.

Regards,
William T (Softwaremaker)
http://www.softwaremaker.net/blog
=========================================

> > Well i am sure the SOAP Response can have nil=true, but if I am
> correct
[quoted text clipped - 17 lines]
>
> Look here: http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx
mflanagan@RemoveThis.MJFlanagan.com - 04 Mar 2005 09:42 GMT
Thanks, Softwaremaker!

I've downloaded your tool, and will use it.  However, my problem isn't
with the XML I am sending, but rather the XML the service is sending,
and how the Serializer *Deserializes* this response.  Or am I missing
something basic (which wouldn't be too surprising)?

Thanks again.

Michael

>To do what Keenan suggested here, you may want to take a look at this tool
>to help you:
[quoted text clipped - 4 lines]
>compile and run the client all the time. Once you can get the message you
>want, then you can manipulate the XMLSerializer to do exactly what you want.

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.