wsdl compile into standalone exe client to consume web service

Discussion in 'ASP .Net Web Services' started by jason@cyberpine.com, Nov 16, 2003.

  1. Guest

    Newbie question.

    I wrote a very simple .net web service and consumed it with remote
    ..aspx after compiling the output of the wsdl produced .vb to .dll
    file. It works as expected.

    Question - Can I access that webservice from dos with standalone exe
    file (no dll on the client). The run of the exe would then display the
    returning string. If so, how?


    =======================
    The Service:
    <%@ WebService Language="vb" Class="nws1.cws1" %>

    Imports System
    Imports System.Web
    Imports System.Web.Services
    Imports System.Data
    Imports System.Text.RegularExpressions


    Namespace nws1
    Public Class xxx1
    Inherits WebService
    <WebMethod()> Public Function yyy1 As String
    dim x as string
    x = "Hello Web Service"
    Return x
    End Function
    End Class
    End Namespace
    ====================

    The client .aspx :
    <%@ Page language="vb"%>
    <%@ Import Namespace="nnn1" %>

    <HTML>
    <BODY>

    <script language="vb" runat="server">

    Public Sub Page_Load(sender As [Object], e As EventArgs)

    Dim mystring As string
    mystring = new nnn1.xxx1().yyy1()
    response.write(mystring)

    End Sub

    </script>

    </BODY>
    </HTML>
    =====================

    My wild (no vb sense) attempt at writing the vb code (a modification
    of the wsdl output file which is intended for the DLL):

    Option Explicit On
    Imports System
    Imports System.ComponentModel
    Imports System.Diagnostics
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.Xml.Serialization
    <System.Diagnostics.DebuggerStepThroughAttribute(), _
    System.ComponentModel.DesignerCategoryAttribute("code"), _
    System.Web.Services.WebServiceBindingAttribute(Name:="xxx1Soap",
    [Namespace]:="http://tempuri.org/")> _
    Public Class xxx1
    Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/fws1",
    RequestNamespace:="http://tempuri.org/",
    ResponseNamespace:="http://tempuri.org/",
    Use:=System.Web.Services.Description.SoapBindingUse.Literal,
    ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
    _
    shared Sub Main
    dim xx as new xxx1()
    xx.Url = "http://111.222.333.444/yy1.asmx"
    Dim results() As Object = xx.Invoke("yyy1", New Object(-1)
    {})
    dim x as string
    x = CType(results(0),String)
    System.Console.WriteLine(x)
    End sub
    Public Function Beginyyy1(ByVal callback As
    System.AsyncCallback, ByVal asyncState As Object) As
    System.IAsyncResult
    Return me.BeginInvoke("yyy1", New Object(-1) {}, callback,
    asyncState)
    End Function

    Public Function Endyyy1(ByVal asyncResult As
    System.IAsyncResult) As String
    Dim results() As Object = me.EndInvoke(asyncResult)
    Return CType(results(0),String)
    End Function


    End Class
    ====
    The above compiles cleanly, but produces runtime errors. Please
    disregard exact code and messages as some items are being masked for
    security reasons.

    Unhandled Exception: System.ArgumentException: yyy1 Web Service method
    name is n
    ot valid.
    at System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRe
    quest request, String methodName, Object[] parameters)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    methodN
    ame, Object[] parameters)
    at xxx1.Main()

    ====
    Another option is to keep the working client dll and write a console
    VB code to use it. That's fine too, but don't know how either.

    Any help or information is greatly appreciated.

    My goal is to be able to test info from a web service in a remote DOS
    stript. I presume I should be able to do this right?
     
    , Nov 16, 2003
    #1
    1. Advertising

  2. Manni Guest

    Start a console apllication project.
    Next add a web reference to your WS.

    From main call a method (or do it in main),
    that generates an instance of the proxy gernated by "add web ref.".

    Call the method an put out the returned string via Console.WriteLine...

    HTH

    Manfred

    <> schrieb im Newsbeitrag
    news:...
    > Newbie question.
    >
    > I wrote a very simple .net web service and consumed it with remote
    > .aspx after compiling the output of the wsdl produced .vb to .dll
    > file. It works as expected.
    >
    > Question - Can I access that webservice from dos with standalone exe
    > file (no dll on the client). The run of the exe would then display the
    > returning string. If so, how?
    >
    >
    > =======================
    > The Service:
    > <%@ WebService Language="vb" Class="nws1.cws1" %>
    >
    > Imports System
    > Imports System.Web
    > Imports System.Web.Services
    > Imports System.Data
    > Imports System.Text.RegularExpressions
    >
    >
    > Namespace nws1
    > Public Class xxx1
    > Inherits WebService
    > <WebMethod()> Public Function yyy1 As String
    > dim x as string
    > x = "Hello Web Service"
    > Return x
    > End Function
    > End Class
    > End Namespace
    > ====================
    >
    > The client .aspx :
    > <%@ Page language="vb"%>
    > <%@ Import Namespace="nnn1" %>
    >
    > <HTML>
    > <BODY>
    >
    > <script language="vb" runat="server">
    >
    > Public Sub Page_Load(sender As [Object], e As EventArgs)
    >
    > Dim mystring As string
    > mystring = new nnn1.xxx1().yyy1()
    > response.write(mystring)
    >
    > End Sub
    >
    > </script>
    >
    > </BODY>
    > </HTML>
    > =====================
    >
    > My wild (no vb sense) attempt at writing the vb code (a modification
    > of the wsdl output file which is intended for the DLL):
    >
    > Option Explicit On
    > Imports System
    > Imports System.ComponentModel
    > Imports System.Diagnostics
    > Imports System.Web.Services
    > Imports System.Web.Services.Protocols
    > Imports System.Xml.Serialization
    > <System.Diagnostics.DebuggerStepThroughAttribute(), _
    > System.ComponentModel.DesignerCategoryAttribute("code"), _
    > System.Web.Services.WebServiceBindingAttribute(Name:="xxx1Soap",
    > [Namespace]:="http://tempuri.org/")> _
    > Public Class xxx1
    > Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
    >

    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.o
    rg/fws1",
    > RequestNamespace:="http://tempuri.org/",
    > ResponseNamespace:="http://tempuri.org/",
    > Use:=System.Web.Services.Description.SoapBindingUse.Literal,
    > ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
    > _
    > shared Sub Main
    > dim xx as new xxx1()
    > xx.Url = "http://111.222.333.444/yy1.asmx"
    > Dim results() As Object = xx.Invoke("yyy1", New Object(-1)
    > {})
    > dim x as string
    > x = CType(results(0),String)
    > System.Console.WriteLine(x)
    > End sub
    > Public Function Beginyyy1(ByVal callback As
    > System.AsyncCallback, ByVal asyncState As Object) As
    > System.IAsyncResult
    > Return me.BeginInvoke("yyy1", New Object(-1) {}, callback,
    > asyncState)
    > End Function
    >
    > Public Function Endyyy1(ByVal asyncResult As
    > System.IAsyncResult) As String
    > Dim results() As Object = me.EndInvoke(asyncResult)
    > Return CType(results(0),String)
    > End Function
    >
    >
    > End Class
    > ====
    > The above compiles cleanly, but produces runtime errors. Please
    > disregard exact code and messages as some items are being masked for
    > security reasons.
    >
    > Unhandled Exception: System.ArgumentException: yyy1 Web Service method
    > name is n
    > ot valid.
    > at

    System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRe
    > quest request, String methodName, Object[] parameters)
    > at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    > methodN
    > ame, Object[] parameters)
    > at xxx1.Main()
    >
    > ====
    > Another option is to keep the working client dll and write a console
    > VB code to use it. That's fine too, but don't know how either.
    >
    > Any help or information is greatly appreciated.
    >
    > My goal is to be able to test info from a web service in a remote DOS
    > stript. I presume I should be able to do this right?
     
    Manni, Nov 16, 2003
    #2
    1. Advertising

  3. Guest

    "Manni" <> wrote in message

    > Start a console apllication > Next add a web reference to your WS.
    > From main call a method (or do it in main),
    > that generates an instance of the proxy gernated by "add web ref.".
    > Call the method an put out the returned string via Console.WriteLine...



    Thanks for response. Yes - I was able to build the console client
    with VS.NET while waiting for response. However, my original goal was
    to code it without VS.NET - possible?. Also, now that I have a working
    exe (produced by vs.net) - it appears that this exe requires a client
    that is running the .net framework to work. Can a web service console
    client be rolled out to a client that is not running the .net
    framework?

    Thanks.
     
    , Nov 16, 2003
    #3
  4. Manni Guest

    Sorry - it seems that I misunderstood your question!

    So first of all - since you asked about the dll - I was thinking, that the
    DLL is the problem you have!
    On the other hand you use wsdl to generate a proxy - so I further thought
    you want .NET.

    By the way - you can merge the proxy code with your exe - even if generated
    by VStudio (there this is default),
    or wsdl - just add the proxy source to your project!

    But that are not your needs I think!

    You want to build an exe without using the .NET framework.
    That means you want to build a Win32 app.
    In VS.NET the only project type supporting this is a C++ application (Win32
    / MFC)!

    With VB (version 6.x I think is the most recent) NOT VB.NET (!!!) you can
    alos build a console application
    I think - a least you can build a windows application with it!

    How ever - if you build an application like this (no .NET) you have to find
    a way to call a webservice from there!
    One way is the Webservice Toolkit (downloadable from MS).
    Another way is XMLDOM - installed with IE I think - otherwise also
    downlaodable as part of the MSXML SDK.

    With XMLDOM you can generate your own SOAP wrapper - no problem if the WS is
    simple!

    The easyest way to achive a simple "give me a string from a WS client" is to
    build a proxy in form of an ASP (ASPX) page.
    Build this page, pass the parameters via the URL (GET) call the WS from
    there and let the page return a simple text!
    For that page you can easy write a client in C++ (MFC) because there are
    classes for "InternetRequest".

    Or you can also write this client by using Sockets, since the protocol
    behind calling a HTTP page is much simpler than
    to call a WS!

    HTH

    Manfred
    By the way - thats one of the strenths of .NET - the easy way to create WS
    clients!!
     
    Manni, Nov 16, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. msnews.microsoft.com
    Replies:
    2
    Views:
    1,162
    =?Utf-8?B?R2FyeQ==?=
    May 19, 2004
  2. Jorge Luzarraga Castro

    Is it possible to consume a Web Service from an ASP Client?

    Jorge Luzarraga Castro, Nov 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    411
    S.M. Altaf [MVP]
    Nov 3, 2005
  3. mohit
    Replies:
    2
    Views:
    823
    Simon Brunning
    Jan 12, 2007
  4. Bert Leu
    Replies:
    1
    Views:
    467
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
  5. dgleeson422111

    consume local web service -ok consume remote service - Not OK

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    1,615
    dgleeson422111
    Jan 31, 2010
Loading...

Share This Page