?
Solved

VB.Net and SOAP web service

Posted on 2010-09-01
7
Medium Priority
?
1,257 Views
Last Modified: 2012-05-10
I am trying to access a SOAP web service using VB.Net (VS2010). The webservice is supposed to return information about a ship (there is a vessel class) when I pass it an IMO number (like a car VIN number). I am having a very hard time getting the overall request and response processed.

The WSDL is located at: http://webservice.vesseltracker.com/VtrServiceService/VtrService?WSDL and I am using the classes getvesselbyimorequest and getvesselbyimoresponse.

Any help getting started is appreciated! Thanks in advance.
my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'wsdl file located at http://webservice.vesseltracker.com/VtrServiceService/VtrService?WSDL

        'prepare to send the request
        Dim svc As New ServiceReference1.getVesselByIMORequest()
        svc.arg0 = "myusername" 'username
        svc.arg1 = "mypassword" 'password
        svc.arg2 = 9288394 'IMO number

        'create a vessel to receive the response
        Dim ship As New vesseltracker_client2.ServiceReference1.vessel

        'call the response
        Dim jdresponse As ServiceReference1.getVesselByIMOResponse(svc)

        'message box that has the ship name
        MsgBox(ship.sName)

    End Sub

Here are the web service classes I am trying to call:

 Partial Public Class getVesselByIMORequest
        
        <System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="http://webservice.ejb.vesseltracker.com/", Order:=0),  _
         System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public arg0 As String
        
        <System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="http://webservice.ejb.vesseltracker.com/", Order:=1),  _
         System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public arg1 As String
        
        <System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="http://webservice.ejb.vesseltracker.com/", Order:=2),  _
         System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public arg2 As Integer
        
        Public Sub New()
            MyBase.New
        End Sub
        
        Public Sub New(ByVal arg0 As String, ByVal arg1 As String, ByVal arg2 As Integer)
            MyBase.New
            Me.arg0 = arg0
            Me.arg1 = arg1
            Me.arg2 = arg2
        End Sub
    End Class

Partial Public Class getVesselByIMOResponse
        
        <System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="http://webservice.ejb.vesseltracker.com/", Order:=0),  _
         System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public [return] As ServiceReference1.vessel
        
        Public Sub New()
            MyBase.New
        End Sub
        
        Public Sub New(ByVal [return] As ServiceReference1.vessel)
            MyBase.New
            Me.[return] = [return]
        End Sub
    End Class

Open in new window

0
Comment
Question by:dobbinjp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Expert Comment

by:xxthiefmasta
ID: 33582294
Are you sure you're using the 'getvesselbyimorequest' correctly?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 33582495
What errors are you getting?

I must admit, I don't use MS based tools. I am surprised that you have to mention "request" or "response" in the use code (rather than the class doing the work).

I've just built the PHP version of the client you would use (I have a wsdl2php script from sourceforge).

To test this, I need a Username/Password and an IMO number.

Based upon the documentation at http://www.vesseltracker.com/download/vesseltracker_api.pdf, I'm getting an exception (see snippet) because I don't have a password.

If you have a test password for the demoxml user, I can test this further.
Request Headers
---------------
POST /VtrServiceService/VtrService HTTP/1.1
Host: webservice.vesseltracker.com
Connection: Keep-Alive
User-Agent: PHP
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 324


Request
-------
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservice.ejb.vesseltracker.com/">
  <SOAP-ENV:Body>
    <ns1:getVesselByIMO>
      <arg0>demoxml</arg0>
      <arg1>Password</arg1>
      <arg2>5060794</arg2>
    </ns1:getVesselByIMO>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Response Headers
----------------
HTTP/1.1 500 Internal Server Error
Date: Wed, 01 Sep 2010 23:39:44 GMT
Server: Apache/Sun Java System Application Server 9.1_02
Content-Type: text/xml;charset="utf-8"
Connection: close
Transfer-Encoding: chunked

Response
--------
<?xml version="1.0"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
      <faultcode>S:Server</faultcode>
      <faultstring>com.vesseltracker.util.exception.IncorrectPasswordException</faultstring>
      <detail>
        <ns2:IncorrectPasswordException xmlns:ns2="http://webservice.ejb.vesseltracker.com/" />
        <ns2:exception xmlns:ns2="http://jax-ws.dev.java.net/" class="com.vesseltracker.util.exception.IncorrectPasswordException"
        note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false">
          <ns2:stackTrace>
            <ns2:frame class="com.vesseltracker.ejb.stateless.UserUtilBean" file="UserUtilBean.java" line="724" method="verifyWebserviceLogin" />
            <ns2:frame class="sun.reflect.GeneratedMethodAccessor322" line="unknown" method="invoke" />
            <ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke" />
            <ns2:frame class="java.lang.reflect.Method" file="Method.java" line="597" method="invoke" />
            <ns2:frame class="com.sun.enterprise.security.application.EJBSecurityManager" file="EJBSecurityManager.java" line="1067" method="runMethod" />
            <ns2:frame class="com.sun.enterprise.security.SecurityUtil" file="SecurityUtil.java" line="176" method="invoke" />
            <ns2:frame class="com.sun.ejb.containers.BaseContainer" file="BaseContainer.java" line="2895" method="invokeTargetBeanMethod" />
            <ns2:frame class="com.sun.ejb.containers.BaseContainer" file="BaseContainer.java" line="3986" method="intercept" />
            <ns2:frame class="com.sun.ejb.containers.EJBLocalObjectInvocationHandler" file="EJBLocalObjectInvocationHandler.java" line="197" method="invoke" />
            <ns2:frame class="com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate" file="EJBLocalObjectInvocationHandlerDelegate.java" line="83" method="invoke" />
            <ns2:frame class="$Proxy144" line="unknown" method="verifyWebserviceLogin" />
            <ns2:frame class="com.vesseltracker.ejb.webservice.VtrService" file="VtrService.java" line="272" method="getVesselByIMO" />
            <ns2:frame class="sun.reflect.GeneratedMethodAccessor1795" line="unknown" method="invoke" />
            <ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke" />
            <ns2:frame class="java.lang.reflect.Method" file="Method.java" line="597" method="invoke" />
            <ns2:frame class="com.sun.enterprise.security.application.EJBSecurityManager" file="EJBSecurityManager.java" line="1067" method="runMethod" />
            <ns2:frame class="com.sun.enterprise.security.SecurityUtil" file="SecurityUtil.java" line="176" method="invoke" />
            <ns2:frame class="com.sun.ejb.containers.BaseContainer" file="BaseContainer.java" line="2895" method="invokeTargetBeanMethod" />
            <ns2:frame class="com.sun.ejb.containers.BaseContainer" file="BaseContainer.java" line="3986" method="intercept" />
            <ns2:frame class="com.sun.ejb.containers.WebServiceInvocationHandler" file="WebServiceInvocationHandler.java" line="189" method="invoke" />
            <ns2:frame class="$Proxy145" line="unknown" method="getVesselByIMO" />
            <ns2:frame class="sun.reflect.GeneratedMethodAccessor1794" line="unknown" method="invoke" />
            <ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke" />
            <ns2:frame class="java.lang.reflect.Method" file="Method.java" line="597" method="invoke" />
            <ns2:frame class="com.sun.enterprise.webservice.InvokerImpl" file="InvokerImpl.java" line="81" method="invoke" />
            <ns2:frame class="com.sun.enterprise.webservice.EjbInvokerImpl" file="EjbInvokerImpl.java" line="82" method="invoke" />
            <ns2:frame class="com.sun.xml.ws.server.InvokerTube$2" file="InvokerTube.java" line="146" method="invoke" />
            <ns2:frame class="com.sun.xml.ws.server.sei.EndpointMethodHandler" file="EndpointMethodHandler.java" line="257" method="invoke" />
            <ns2:frame class="com.sun.xml.ws.server.sei.SEIInvokerTube" file="SEIInvokerTube.java" line="93" method="processRequest" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="595" method="__doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="554" method="_doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="539" method="doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="436" method="runSync" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl" file="AbstractTubeImpl.java" line="106" method="process" />
            <ns2:frame class="com.sun.enterprise.webservice.MonitoringPipe" file="MonitoringPipe.java" line="147" method="process" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.helper.PipeAdapter" file="PipeAdapter.java" line="115" method="processRequest" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="595" method="__doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="554" method="_doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="539" method="doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="436" method="runSync" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl" file="AbstractTubeImpl.java" line="106" method="process" />
            <ns2:frame class="com.sun.xml.ws.tx.service.TxServerPipe" file="TxServerPipe.java" line="317" method="process" />
            <ns2:frame class="com.sun.enterprise.webservice.CommonServerSecurityPipe" file="CommonServerSecurityPipe.java" line="218" method="processRequest" />
            <ns2:frame class="com.sun.enterprise.webservice.CommonServerSecurityPipe" file="CommonServerSecurityPipe.java" line="129" method="process" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.helper.PipeAdapter" file="PipeAdapter.java" line="115" method="processRequest" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="595" method="__doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="554" method="_doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="539" method="doRun" />
            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="436" method="runSync" />
            <ns2:frame class="com.sun.xml.ws.server.WSEndpointImpl$2" file="WSEndpointImpl.java" line="243" method="process" />
            <ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit" file="HttpAdapter.java" line="444" method="handle" />
            <ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter" file="HttpAdapter.java" line="244" method="handle" />
            <ns2:frame class="com.sun.xml.ws.transport.http.servlet.ServletAdapter" file="ServletAdapter.java" line="135" method="handle" />
            <ns2:frame class="com.sun.enterprise.webservice.Ejb3MessageDispatcher" file="Ejb3MessageDispatcher.java" line="113" method="handlePost" />
            <ns2:frame class="com.sun.enterprise.webservice.Ejb3MessageDispatcher" file="Ejb3MessageDispatcher.java" line="87" method="invoke" />
            <ns2:frame class="com.sun.enterprise.webservice.EjbWebServiceServlet" file="EjbWebServiceServlet.java" line="226" method="dispatchToEjbEndpoint" />
            <ns2:frame class="com.sun.enterprise.webservice.EjbWebServiceServlet" file="EjbWebServiceServlet.java" line="155" method="service" />
            <ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="831" method="service" />
            <ns2:frame class="com.sun.enterprise.web.AdHocContextValve" file="AdHocContextValve.java" line="114" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="632" method="doInvoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="577" method="doInvoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="571" method="invoke" />
            <ns2:frame class="com.sun.enterprise.web.WebPipeline" file="WebPipeline.java" line="87" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.StandardHostValve" file="StandardHostValve.java" line="206" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="632" method="doInvoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="577" method="doInvoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="571" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.ContainerBase" file="ContainerBase.java" line="1080" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.StandardEngineValve" file="StandardEngineValve.java" line="150" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="632" method="doInvoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="577" method="doInvoke" />
            <ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="571" method="invoke" />
            <ns2:frame class="org.apache.catalina.core.ContainerBase" file="ContainerBase.java" line="1080" method="invoke" />
            <ns2:frame class="org.apache.coyote.tomcat5.CoyoteAdapter" file="CoyoteAdapter.java" line="272" method="service" />
            <ns2:frame class="org.apache.jk.server.JkCoyoteHandler" file="JkCoyoteHandler.java" line="200" method="invoke" />
            <ns2:frame class="org.apache.jk.common.HandlerRequest" file="HandlerRequest.java" line="283" method="invoke" />
            <ns2:frame class="org.apache.jk.common.ChannelSocket" file="ChannelSocket.java" line="773" method="invoke" />
            <ns2:frame class="org.apache.jk.common.ChannelSocket" file="ChannelSocket.java" line="703" method="processConnection" />
            <ns2:frame class="org.apache.jk.common.ChannelSocket$SocketConnection" file="ChannelSocket.java" line="895" method="runIt" />
            <ns2:frame class="org.apache.tomcat.util.threads.ThreadPool$ControlRunnable" file="ThreadPool.java" line="666" method="run" />
            <ns2:frame class="java.lang.Thread" file="Thread.java" line="619" method="run" />
          </ns2:stackTrace>
        </ns2:exception>
      </detail>
    </S:Fault>
  </S:Body>
</S:Envelope>


Exception
---------
com.vesseltracker.util.exception.IncorrectPasswordException

Open in new window

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 33582505
OOI. If you want the PHP code, let me know.
0
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 

Author Comment

by:dobbinjp
ID: 33583280
I am not sure I am using the code correctly...long story short, but vesseltracker.com's IT people couldn't give me an example of working code (in any language) nor could they tell me if I am on the right path. I would be interested in seeing the php code...it might be useful and help me figure out how to translate into .Net.

On the question about using both request and response, I had originally thought the same thing...I will try to get something going in the morning and post some more detailed error messages.

Thanks!
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 2000 total points
ID: 33584103
0
 

Author Comment

by:dobbinjp
ID: 33591980
So I finally made some progress. After playing around with the code, I tried another part of the service, "vtrserviceclient" and it looks like I have got it. I got an "unauthorized exception" error (it has been a while since I was on the site...I think my account was de-activated), then I intentionally passed a bad username at it and got a "username not found" exception with my code. I got the same results from the "tester" page...once I confirm that my account is re-activated, I am pretty sure I have it.

RQuadling, thanks for sending the php code, that helped me formulate my VB.NET code. I will accept your post as the solution. My code is included here for anyone else who runs into this issue. Thanks, everyone!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'initiate service
        Dim svc As New ServiceReference1.VtrServiceClient

        'set up an instance of vessel class to contain ship information
        Dim jdvessel As New ServiceReference1.vessel

        'variable to store ship name
        Dim shipname As String

        Try
            jdvessel = svc.getVesselByIMO("myusername", "mypassword", 9235050)
            shipname = jdvessel.sName.ToString
            MsgBox(shipname)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

Open in new window

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 33592163
I'm glad to have helped and thank you for showing your code too. It is good to see the comparison/similarities.
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For some reason Google Apps has decided to reserve 'www' for your new domain which results in an error when trying to map the web address 'www' to a certain site in your Google Sites. The error is 'this address is already being used' and after some …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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