Web Service - Query
-
Hi All I am looking for a solution to a problem regarding web service. I want to call a web method of a web service, but I don’t want to use wsdl nor can I generate the proxy class. The scenario is that, in my application user can fill in the web service address and a list of methods with parameters, he wants to execute and I have to get the results. I have some solution to this problem. Right now i am using WSE to solve this problem. My code is:
Dim env As SoapEnvelope Dim epr As EndpointReference Dim client As MyHttpClient Dim rs As SoapEnvelope Dim bodyResponse As String env = New SoapEnvelope env.Context.Addressing.Action = New Action("http://tempuri.com/TestWebService/MyService/HelloWorld") env.CreateBody() ** env.Body.InnerXml = String.Format("")** epr = New EndpointReference(New Uri("http://localhost/TestWebService/MyService.asmx")) client = New MyHttpClient(epr) rs = client.Hello\_World(env) bodyResponse = rs.Body.OuterXml TestReport.Text = bodyResponse
Imports System.Xml
Imports Microsoft.Web.Services2
Imports Microsoft.Web.Services2.Addressing
Imports Microsoft.Web.Services2.Messaging
Imports System.WebPublic Class MyHttpClient
Inherits SoapClientPublic msg As String = String.Empty Public LoadTesterForm As LoadTesterForm = Nothing Public Sub New(ByVal dest As EndpointReference) MyBase.New(dest) End Sub \_ Public Function Hello\_World(ByVal envelope As SoapEnvelope) As SoapEnvelope Dim response As SoapEnvelope response = MyBase.SendRequestResponse("HelloWorld", envelope) msg = response.Body.OuterXml Hello\_World = response End Function Protected Overrides Sub FilterMessage(ByVal envelope As Microsoft.Web.Services2.SoapEnvelope) MyBase.FilterMessage(envelope) End Sub
End Class
I am getting the response back with this code. Main problem is env.Body.InnerXml, Here we need to specify all the parameters & method name as XML. But i dont have parameter names. One solution to this problem might be i can generate proxy class at runtime. Can anybody guide me to the right direction? Thanks a lot Sumit Domyan