Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Web Service - Query

Web Service - Query

Scheduled Pinned Locked Moved C#
databasewcfcomxmlhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sumit Domyan
    wrote on last edited by
    #1

    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.Web

    Public Class MyHttpClient
    Inherits SoapClient

    Public 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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups