By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,584 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Help please: Exception when with <input type="file"> but not with Textbox

P: n/a
I've encounted a pretty strange problem and I'm not quite sure what to make
of it.

I have a web service that consumes an XML file as well as a few other
parameters. This web service works fine if I use the web test interface. It
also works fine if I call it from an ASP.NET page that has a text box where
the XML is pasted and then passed on. However, I get an exception if I use
an <input type="file"> control on the ASP page that allows the user to load
the XML file before posting back to the server.

I've added a temporary text box to this ASP.NET page so that I could
actually load *both* values and compare the two.

Here's the kicker, when I compare the two strings they are *identical*! Yet,
if I subsequently call the web service twice: once with the XML pasted into
the text box and then a second time with the XML loaded from the <input
type="file"> control, the later call fails!

Here is a code snippet to show what i'm talking about:

' strXMLContent is a string that is holding the contents of a file loaded by
the user
' with the <input type="file"> control
' txtTemp.Text is the contents of the exact same file that were pasted into
the ASPX page
' Notice that the comparison below shows the strings are *EXACTLY THE SAME*
If (String.Compare(strXMLContent, txtTemp.Text) = 0) Then
_lblStatusLabel.Text = "XML content is identical"
_lblStatusLabel.Text = "XML content is not the same."
End If

' This call succeeds
bytePDF = wsPDF.CreatePDF(txtTemp.Text,
TestDWS_ASPX.PDF_WS.WatermarkID.TSILogo, enDealPart)
' This call throws an exception
bytePDF = wsPDF.CreatePDF(strXMLContent,
TestDWS_ASPX.PDF_WS.WatermarkID.TSILogo, enDealPart)

Here is the text of the exception:
'', hexadecimal value 0x00, is an invalid character. Line 6, position 117.
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.Xml.XmlException: '', hexadecimal value 0x00, is
an invalid character. Line 6, position 117.

Source Error:

Line 40:
<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("http://localhost/DWS/CreatePDF",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped)>
Line 41: Public Function CreatePDF(ByVal xmlTSI As String, ByVal
nWatermarkID As WatermarkID, ByVal enDealPart As dpDealPart) As
<System.Xml.Serialization.XmlElementAttribute(Data Type:="base64Binary")>
Line 42: Dim results() As Object = Me.Invoke("CreatePDF", New
Object() {xmlTSI, nWatermarkID, enDealPart})
Line 43: Return CType(results(0),Byte())
Line 44: End Function
Source File: C:\TSI\MyProjects\DWS\TestDWS_ASPX\Web
References\PDF_WS\Reference.vb Line: 42

Stack Trace:

[XmlException: '', hexadecimal value 0x00, is an invalid character. Line 6,
position 117.]
System.Xml.XmlTextReader.ParseBeginTagExpandCharEn tities() +1036
System.Xml.XmlTextReader.Read() +216
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadSoapException(XmlReader
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
TestDWS_ASPX.PDF_WS.DWS.CreatePDF(String xmlTSI, WatermarkID
nWatermarkID, dpDealPart enDealPart) in
C:\TSI\MyProjects\DWS\TestDWS_ASPX\Web References\PDF_WS\Reference.vb:42
TestDWS_ASPX.WebForm1._btnCreatePDF_Click(Object sender, EventArgs e) in
C:\TSI\MyProjects\DWS\TestDWS_ASPX\index.aspx.vb:1 01
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain() +1292


At first I thought that perhaps when I was decoding the uploaded file that I
was using the wrong encoder. However, I have since tried using a UTF-8
encoder and it didn't fix anything.

Does anyone have *any clues* as to what is going on?

Thank you in advance for your assistance. Any input at all is greatly

Drew Berkemeyer
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.