I hopeful that someone can provide me with a bit of help. I have developed the below ASP.net web service (web service A) that calls another web service B. The aim of the web service A is to accept bank account details as parameters and generate some SOAP XML and post this to web service B capturing the SOAP Envelope response from web service B and then passing this back to web service A. The issue is that I need pass back the SOAP envelope resonse from web service B back exactly to web service A and cannot get it right. I can get the SOAP response from web service B ok but there is additional XML at the end that relates to web service A. Basically my SOAP response in web service A is a combination of the response from B + the reponse from A. Hope this makes sense - maybe the code below will be easier to read!
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Net
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
'
Public Class Service1
Inherits System.Web.Services.WebService
Public Sub bankData(ByVal accountNumber As String, ByVal sortCode As String, ByVal country As String)
'Retreive web service endpoint from web.config
Dim endPoint As String = System.Web.Configuration.WebConfigurationManager.AppSettings("endPoint").ToString()
'Define the SOAP XML and convert to Byte
Dim bytArguments As Byte() = System.Text.Encoding.ASCII.GetBytes( _
"
"
"
"
"
"
"
"
"
"
' Run the web service
runWebService(bytArguments, endPoint)
End Sub
Sub runWebService(bytArgumentsVal As Byte(), endPoint As String)
'Define web client var
Dim manualWebClient As New System.Net.WebClient()
'Get CC&B user credentials from web.config file
Dim user As String = System.Web.Configuration.WebConfigurationManager.AppSettings("userVal").ToString()
Dim password As String = System.Web.Configuration.WebConfigurationManager.AppSettings("passVal").ToString()
' Define content type and add CC&B login details to the HTTP header
manualWebClient.Headers.Add("Content-Type", "application/soap+xml; charset=utf-8")
manualWebClient.Credentials = New NetworkCredential(user, password)
Try
'Post to web service
Dim bytRetData As Byte() = manualWebClient.UploadData(endPoint, "POST", bytArgumentsVal)
'Read response
'Return System.Text.Encoding.ASCII.GetString(bytRetData)
Context.Response.Write(System.Text.Encoding.ASCII.GetString(bytRetData))
Catch x As System.Net.WebException
' Return errors
'Return x.Message
Context.Response.Write(x.Message)
End Try
End Sub
End Class
The above program will receive the following Request:
And will return below - I do not want it to return the highlighted text:
Thanks in Advance
Sean
Replies
Know the answer? Post it — somebody with the same question will find it here.