Soap Extension and error being returned
Hello.
I am writing a web service and I need to use a Soap Extension to add a custom header that is expected at the destination. I can use the Soap Extension successfully for adding the header in the AfterSerialize section and the destination accepts my request and sends back the appropriate data, but my problem comes when I try to return the data. Depending on what I do in the BeforeDeserialize staage I either get an exception that "the root element is missing" or being returned Nothing. I know I am getting proper response back because I can see the response using Fiddler.
The sub which calls the webservice in my proxy class is:
Public Sub ProcessMessage(ByRef payload As Payload)
Try
Dim results() As Object = Me.Invoke("ProcessMessage", New Object() {payload})
payload = CType(results(0), Payload)
Catch ex As Exception
Dim em As String = ex.Message()
End Try
End Sub
Some of the code in my soap extension:
Public Overrides Function ChainStream(ByVal stream As Stream) As Stream
MessageStream = stream
InternalStream = New MemoryStream
Return InternalStream
End Function
Sub Copy(ByVal fromStream As Stream, ByVal toStream As Stream)
Dim reader As New StreamReader(fromStream)
Dim writer As New StreamWriter(toStream)
writer.WriteLine(reader.ReadToEnd())
writer.Flush()
End Sub
If I have the following code in the soap extension:
Public Overrides Sub ProcessMessage(ByVal message As System.Web.Services.Protocols.SoapMessage)
Select Case message.Stage
Case SoapMessageStage.BeforeDeserialize
Copy(MessageStream, InternalStream)
InternalStream.Position = 0
I get Nothing returned.
If I have the following code:
Public Overrides Sub ProcessMessage(ByVal message As System.Web.Services.Protocols.SoapMessage)
Select Case message.Stage
Case SoapMessageStage.BeforeDeserialize
' do nothing
I get an error which says "the root element is missing."
I really have no idea what my problem is and why i cannot get a value back. If anyone can offer some advice and/or code to help solve this problem I would greatly appreciate it!
Thank you,
Kelly
|