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

VB.Net and SOAP web service

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
dobbinjp
Asked:
dobbinjp
  • 4
  • 2
1 Solution
 
xxthiefmastaCommented:
Are you sure you're using the 'getvesselbyimorequest' correctly?
0
 
Richard QuadlingSenior Software DeverloperCommented:
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
 
Richard QuadlingSenior Software DeverloperCommented:
OOI. If you want the PHP code, let me know.
0
2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

 
dobbinjpAuthor Commented:
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
 
Richard QuadlingSenior Software DeverloperCommented:
0
 
dobbinjpAuthor Commented:
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
 
Richard QuadlingSenior Software DeverloperCommented:
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

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

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