• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

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

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
k3n51mm
Asked:
k3n51mm
  • 2
1 Solution
 
nepaliCommented:
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
 
k3n51mmAuthor Commented:
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
 
k3n51mmAuthor Commented:
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
 
Computer101Commented:
PAQed, with points refunded (250)

Computer101
E-E Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now