I know this thread is old, but have a question on this - I have the following code in B4A to upload a picture taken with the smartphone camera to the server:
Dim j As HttpJob
j.Initialize("PostImage", Me)
j.PostFile("http://" & Starter.IPAddr & "/imgupload.asmx", Dir, OrigFileName)
And the following in the file imgupload.asmx on the server:
Dim length As Integer = Convert.ToInt32(Context.Request.InputStream.Length)
Dim buffer() As Byte = New Byte((length) - 1) {}
Context.Request.InputStream.Read(buffer, 0, length)
Dim ms As MemoryStream = New MemoryStream(buffer)
Dim file As New FileStream("test.jpg", FileMode.Create, FileAccess.Write)
ms.WriteTo(file)
file.Close()
ms.Close
Dim js As JavaScriptSerializer = New JavaScriptSerializer
Context.Response.Expires = -1
Context.Response.ContentType = "application/json"
Context.Response.Write(js.Serialize("test response"))
Context.Response.End
But this is returning "Internal Server Error". Does anything pop out as incorrect? Any ideas on how to debug this?
P.S., I'm testing this on my localhost IIS server on my PC.
Here's the error stack:
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (profileedit) Resume **
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="
http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="soap:Receiverhttp://
www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Invalid character in the given encoding. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
at System.Xml.XmlTextReaderImpl.ReadData()
at System.Xml.XmlTextReaderImpl.SwitchEncoding(Encoding newEncoding)
at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl)
at System.Xml.XmlTextReaderImpl.Read()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()
at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
--- End of inner exception stack trace ---</soap:Text></soap:Reason><soap
etail /></soap:Fault></soap:Body></soap:Envelope>
JobDone(PostImage):false
Internal Server Error