473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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"
Else
_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",
RequestNamespace:="http://localhost/DWS/",
ResponseNamespace:="http://localhost/DWS/",
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")>
Byte()
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.XmlScanner.ScanHexEntity()
System.Xml.XmlTextReader.ParseBeginTagExpandCharEn tities() +1036
System.Xml.XmlTextReader.Read() +216
System.Xml.XmlReader.ReadElementString()
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadSoapException(XmlReader
reader)
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
eventArgument)
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
appreciated.

Sincerely,
Drew Berkemeyer
Nov 21 '05 #1
0 1548

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jesper Hermansen | last post by:
Hi! I'm making a system that will generate Winamp-playlists. To make it easy for the user to add a file to the list, I'm using <input type="file">. The problem with this is that I only get...
1
by: Matt | last post by:
When we click Browse button, <input type="FILE">, can we set the default of the directory to open?? For example, C:\MYFILES are open when the file open dialog is opened. please advise. thanks!!
2
by: Laermans_k | last post by:
Hi, Does anyone have a solution to use the <input type="file" id="filechooser"> and the <input type="submit" id="submitbutton"> in 1 button click? I've already tried to create a javascript...
1
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic...
7
by: Drew Berkemeyer | last post by:
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...
2
by: Tarkeshwar | last post by:
Hi All, I want to restrict the user from being entering the value in <input type="file">. It works fine in IE but not in Mozilla. I am sending my code also which works in IE and not in Mozilla.Can...
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
3
by: Gert | last post by:
Would it be possible to access the file CONTENT in codebehind for a standard: <input id="htmlFile" type="file" /> Then in codebehind: foreach (string keyName in...
3
by: eeeeman | last post by:
This one has really got me! Im trying to write a value to a input type="file" form element using client-side javascript. I have tried the obvious, simply writing: <input type="file" ...
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.