Solved

calling a web service from asp.net/vb without visual studio

Posted on 2004-08-12
5
327 Views
Last Modified: 2006-11-17
Our online application needs to consume a web service to implement a GIS system.

We do not use Visual Studio.

Using Web Matrix, I followed the simple process of simply typing in the URL of the WSDL of the service, giving it a namespace to refer to (let's say, 'mapTest'), creating the proxy dll, dropping it into the /bin directory; then I tried to call its methods from the appropriate ASP.Net page.

However, when I attempt to call a method (the only one of interest is 'getMaps()', I always get the following error: "getMaps() is not a member of mapTest."

I've tried this with the dll, using a codebehind file of the vb source, and et cetera. I have no idea what the problem is. I guess I'm lost with all the 'Namespace' junk. There's a class defined in the vb file of course, but I'm confused as to where or how I should bring the code into being available from the aspx file. I've tried using the <%@import namespace%> directive, but I don't know what to put in there. I also tried putting an 'inherits' attribute in the page declaration and using the vb file Web Matrix generated; but after getting the syntax correct after much trial and error, I end up with the same error: 'getMaps() is not a member of mapTest'.

I was under the impression that the dll file generated by Web Matrix (or whatever compiler you use) was supposed to encapsulate the interface with the web service and simply expose the methods available. But after dropping the generated dll into /bin and calling getMaps() by itself, I get the error "getMaps() is not declared". If I qualify the getMaps() function call with the namespace I used when generating the dll - this amounts to mapTest.getMaps() - then I'm back to the original error, that getMaps is not a mamber of mapTest.

I'm obviously not getting anywhere, so any input is appreciated. I may give extra points if the solution is quick, complete and correct! Thanks in advance!
0
Comment
Question by:k3n51mm
  • 2
5 Comments
 
LVL 7

Expert Comment

by:nepali
Comment Utility
HI,
I really don't know how does web matrix works when generating proxies.. what u can try is trying generating the proxy using the wsdl utility at command prompt.. for eg.

wsdl /language:VB /out:myProxyClass.vb http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

it will generate a .vb file for u... look at the source code and see the namespace hierarchy.. then compile the .vb to a dLL using the normal way.. and then try using it in the asp.net page.

Regards
Mahendra

0
 
LVL 1

Author Comment

by:k3n51mm
Comment Utility
Thanks for the response,

when you say:  "look at the source code and see the namespace hierarchy.. "

I guess that's my problem. I don't know what I'm looking for. Here is what wsdl generated, which by the way I did already try, and web matrix generates exactly the same file. By seeing the namespace hierarchy in the code below, how would you 1)reference the compiled dll and 2)call the method below called getMaps()? That's what I need to know. A code example is all that I can understand at this point, since I'm not experienced enough as a web service/SOAP developer to be able to interpolate non-code comments. Thanks.

'------------------------------------------------------------------------------
' <autogenerated>
'     This code was generated by a tool.
'     Runtime Version: 1.1.4322.573
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

'
'This source code was auto-generated by wsdl, Version=1.1.4322.573.
'

'<remarks/>
<System.Diagnostics.DebuggerStepThroughAttribute(),  _
 System.ComponentModel.DesignerCategoryAttribute("code"),  _
 System.Web.Services.WebServiceBindingAttribute(Name:="SampleLocationSoapQueryServerSoapBinding", [Namespace]:="http://demos.latitudegeo.com/imf406_soap/services/SampleLocationSoapQueryServer")>  _
Public Class SampleLocationSoapQueryServerService
    Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
   
    '<remarks/>
    Public Sub New()
        MyBase.New
        Me.Url = "http://demos.latitudegeo.com/imf406_soap/services/SampleLocationSoapQueryServer"
    End Sub
   
    '<remarks/>
    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)>  _
    Public Function getMaps(<System.Xml.Serialization.XmlElementAttribute("getMaps", [Namespace]:="http://sampleLocationSoapQuery.geocortex.net")> ByVal getMaps1 As Object) As <System.Xml.Serialization.XmlElementAttribute("getMapsReturn", [Namespace]:="http://demos.latitudegeo.com/imf406_soap/services/SampleLocationSoapQueryServer")> Object
        Dim results() As Object = Me.Invoke("getMaps", New Object() {getMaps1})
        Return CType(results(0),Object)
    End Function
   
    '<remarks/>
    Public Function BegingetMaps(ByVal getMaps1 As Object, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
        Return Me.BeginInvoke("getMaps", New Object() {getMaps1}, callback, asyncState)
    End Function
   
    '<remarks/>
    Public Function EndgetMaps(ByVal asyncResult As System.IAsyncResult) As Object
        Dim results() As Object = Me.EndInvoke(asyncResult)
        Return CType(results(0),Object)
    End Function
End Class
0
 
LVL 1

Author Comment

by:k3n51mm
Comment Utility
Okay, in case anyone comes here looking for the answer to this:

wsdl.exe is not to be trusted to provide a turnkey solution for creating a proxy dll. End of story. Use it for a template, then customize it, unless you have the most innocuous web service in town.

The first time I ran it, it assigned a datatype of String to a parameter expected in both synchronous and asynchronous SOAP messages. The second time, it did a little better: it assigned a datatype of Object. I was passing a system.data.dataset type to the service; so I had to manually recompile the dll using vbc in the Framework SDK from the command line, after making the following changes:

Add to .vb source file:    Imports system.data
Add to aspx file:            dim new instance of web service object, not just call it implicitly

change in vb source: references to the input parameter getMaps1 (listed above) to type DataSet

recompile using vbc. I also created a .rsp file and added it to the compilation command, so I'd get all the Framework libraries if needed, without having to manually type them in every time I run vbc. Google for it and you'll find it.

That's it. Microsoft adds a bunch of stuff to the outgoing SOAP message as well, so be prepared to beg your web service provider to filter it all out before it will work right for you. This stuff is still a bit of a black art, but I guess the technology's still a little immature. I earned my own 250 points this time.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now