SOAP with attachments in VB.NET

I need to use the web service that was provided to me and which uses SOAP with attachments as a means of communication. It also uses WS-Security 1.0 as a form of authentication (the user transmits plain text).

I will work on VB.NET, and my experience with web services is very thin and comes to the creation of a WCF web service by adding a link to the service in another project, thus creating a proxy class and using methods.

I searched the Internet and found that VB.NET does not have native SwA support, is this correct? An example of how I can approach communication, and some indication of where I can better know these concepts will be excellent.

+5
source share
3 answers

# WebService. , soapenvelope - HttpWebRequest. WebRespons - . , XmlDocument, , .

soapenvelope, , ( ), soapenvelope ( )

soapenvelope -, SOAPUI, , ! , ,..

+1

?

Public Class SoapPackage
    Public Property AttachmentName() As String
        Get
            Return m_AttachmentName
        End Get
        Set
            m_AttachmentName = Value
        End Set
    End Property
    Private m_AttachmentName As String

    ' put your file data in here 
    Public Property AttachmentData() As Byte()
        Get
            Return m_AttachmentData
        End Get
        Set
            m_AttachmentData = Value
        End Set
    End Property
    Private m_AttachmentData As Byte()
End Class

- ( , ):

Public Shared Function StreamToByteArray(input As Stream) As Byte()
    Dim buffer As Byte() = New Byte(16 * 1024 - 1) {}
    Using ms As New MemoryStream()
        Dim read As Integer
        While (InlineAssignHelper(read, input.Read(buffer, 0, buffer.Length))) > 0
            ms.Write(buffer, 0, read)
        End While
        Return ms.ToArray()
    End Using
End Function

:

, StreamToByteArray :

Dim filePath as String = "Path\to\file"
Dim fileBytes as Byte() = System.IO.File.ReadAllBytes(filePath)
+1

As far as I can tell about this: http://www.w3.org/TR/SOAP-attachments , the attachments should be embedded in the body of the message, which means that you need to combine the answers from Kevin and Tom to build your message.

I noticed that SOAP with attachments seems to be only a representation, not a standard, moreover, it is quite outdated.

Assuming you need to use the web service "as is", I would try to get additional data or examples from the creator / provider of the service, if you can.

0
source

All Articles