Forum Discussion

LMSSML's avatar
13 years ago

Webservice to recive files

Hi there,

I made a webservice to recive xml base64 files,structure like these.

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.IO
Imports System.Xml

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function GimmeMyFile(ByVal fileName As String, ByVal offset As Integer, ByVal length As Integer, ByVal path As String) As Byte()
'Do whatever magic you need to do to get the file and transfer it into a bytestream.
'A simple example is this:
Dim fs As New System.IO.FileStream("C:\a\" & fileName, System.IO.FileMode.Open)
Dim len As Integer = fs.Length
'If you are requesting bytes beyond file length, abort.
If offset > len Then
Return New Byte(-1) {}
End If
'else get the file
If len < offset + length Then
'if you are at the end of file, you need less bytes.
len = len - offset
Else
len = length
End If
Dim barr As Byte() = New Byte(len - 1) {}
fs.Read(barr, offset, len)
Return barr
End Function
End Class


And tried to comunicate with soapui
with these envelope:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tem="http://tempuri.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ps:resize
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ps="http://psol.com/2004/ws/resize"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<source href="cid:testenovo2.xml"/>
<percent>5</percent>
</ps:resize>
</soapenv:Body>
</soapenv:Envelope>


Althouth I have the two expiriences:

First it was writing the file on folder with 0K (so empty)
But then it becomes with another problem:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. ---> Could not find a part of the path 'C:\a\'.</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>

On the first test it wrotes the file with 0k but then it becomes with these text.

Any help ?
No RepliesBe the first to reply