Consuming (SOAP)webservice in vb.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henrik

    Consuming (SOAP)webservice in vb.net

    Hi all,,

    I'm trying to make a program, that calls a webservice, and then does
    somthing about the data, that i recive..

    But i don't know what to do with this data??.. i tried to load into an
    xmldocument, but i recives an error??

    If i load it ito an object by:

    Dim myProxy As New Proxy_WebServic e.function1()
    Dim obj As Object

    obj = myProxy.functio nGetData("1", "2004-11-27")

    Then the obj contains an system.array wich have 2 System.Xml.XmlA ttribute
    and 1 System.Xml.XmlE lement

    How does i get that "readable"? ? do i have to make an XmlFormatter or??


    Another question: is it nesscery to any thing else to the wsdl-deffiniton??
    I have only add'ed the .vb-file to my project. And then started using it.. og
    do i have to convert it into an .dll-file??
  • Drew Marsh

    #2
    Re: Consuming (SOAP)webservic e in vb.net

    Henrik wrote:
    [color=blue]
    > Then the obj contains an system.array wich have 2
    > System.Xml.XmlA ttribute and 1 System.Xml.XmlE lement
    >
    > How does i get that "readable"? ? do i have to make an XmlFormatter
    > or??
    >
    > Another question: is it nesscery to any thing else to the
    > wsdl-deffiniton?? I have only add'ed the .vb-file to my project. And
    > then started using it.. og do i have to convert it into an .dll-file??[/color]

    I'd like to help, but I can't quite figure out what might be going on here.
    Can you post the signature that was generated for the proxy? And, if possible,
    the WSDL you generated the proxy from?

    Thanks,
    Drew

    Comment

    • Henrik

      #3
      Re: Consuming (SOAP)webservic e in vb.net

      "Drew Marsh" wrote:
      [color=blue]
      > Henrik wrote:
      >[color=green]
      > > Then the obj contains an system.array wich have 2
      > > System.Xml.XmlA ttribute and 1 System.Xml.XmlE lement
      > >
      > > How does i get that "readable"? ? do i have to make an XmlFormatter
      > > or??
      > >
      > > Another question: is it nesscery to any thing else to the
      > > wsdl-deffiniton?? I have only add'ed the .vb-file to my project. And
      > > then started using it.. og do i have to convert it into an .dll-file??[/color]
      >
      > I'd like to help, but I can't quite figure out what might be going on here.
      > Can you post the signature that was generated for the proxy? And, if possible,
      > the WSDL you generated the proxy from?
      >
      > Thanks,
      > Drew
      >
      >[/color]

      Hi Drew, and thanks :o)

      I don't have any signature generated?? Whats that? .. The only thing i've
      done, is generated the WSDL from at site: eg.

      wsdl /language:VB /out:C:\myProxyC lass.vb


      and then loaded the "myProxyClass.v b"-file into my vb.net project, and begin
      using it..


      **************O utput of the WSDL*********** **************

      '------------------------------------------------------------------------------
      ' <autogenerate d>
      ' This code was generated by a tool.
      ' Runtime Version: 1.0.3705.288
      '
      ' 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.Componen tModel
      Imports System.Diagnost ics
      Imports System.Web.Serv ices
      Imports System.Web.Serv ices.Protocols
      Imports System.Xml.Seri alization

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

      '<remarks/>
      <System.Diagnos tics.DebuggerSt epThroughAttrib ute(), _
      System.Componen tModel.Designer CategoryAttribu te("code"), _

      System.Web.Serv ices.WebService BindingAttribut e(Name:="Regist rationsPortSoap Binding", [Namespace]:="http://xxx.xx/Webservices/Registration")> _
      Public Class Registrations
      Inherits System.Web.Serv ices.Protocols. SoapHttpClientP rotocol

      '<remarks/>
      Public Sub New()
      MyBase.New
      Me.Url = "http://xxx.xx/Webservices/Registration"
      End Sub

      '<remarks/>
      <System.Web.Ser vices.Protocols .SoapRpcMethodA ttribute("",
      RequestNamespac e:="http://xxx.xx/Webservices/Registration",
      ResponseNamespa ce:="http://xxx.xx/Webservices/Registration")> _
      Public Function GetRegistration s(ByVal UserID As String,
      <System.Xml.Ser ialization.Soap ElementAttribut e(DataType:="da te")> ByVal
      DateTime As Date) As <System.Xml.Ser ialization.Soap ElementAttribut e("data")>
      Object
      Dim results() As Object = Me.Invoke("GetR egistrations", New Object()
      {UserID, DateTime})
      Return CType(results(0 ),Object)
      End Function

      '<remarks/>
      Public Function BeginGetRegistr ations(ByVal UserID As String, ByVal
      DateTime As Date, ByVal callback As System.AsyncCal lback, ByVal asyncState As
      Object) As System.IAsyncRe sult
      Return Me.BeginInvoke( "GetRegistratio ns", New Object() {UserID,
      DateTime}, callback, asyncState)
      End Function

      '<remarks/>
      Public Function EndGetRegistrat ions(ByVal asyncResult As
      System.IAsyncRe sult) As Object
      Dim results() As Object = Me.EndInvoke(as yncResult)
      Return CType(results(0 ),Object)
      End Function

      End Class

      *************** *******WSDL END************ *************

      I also don't quite known
      how to call to 2 functions BeginGetRegistr ations and
      EndGetRegistrat ions??


      In the meantime if found out that i throug a WebRequest's -
      response.GetRes ponseStream(), get's a valid xml-document, to view in
      Explorer.. but then i don't use the WSDL.. And i don't know how to
      deserielize it in my vb code??

      Comment

      • Drew Marsh

        #4
        Re: Consuming (SOAP)webservic e in vb.net

        Henrik wrote:
        [color=blue]
        > I don't have any signature generated?? Whats that? .. The only thing
        > i've done, is generated the WSDL from at site: eg.
        >
        > wsdl /language:VB /out:C:\myProxyC lass.vb
        > http://xxx.xx/Webservices/Registration?wsdl
        >
        > and then loaded the "myProxyClass.v b"-file into my vb.net project, and
        > begin using it..[/color]

        What I meant by signature was the signature of the method on your proxy class
        that represents the web method. I just wanted to see what was generated for
        you so I had a better idea what types you were working with. The output you
        pasted me is exactly what I was looking for. :)
        [color=blue]
        > <System.Web.Ser vices.Protocols .SoapRpcMethodA ttribute("",
        > RequestNamespac e:="http://xxx.xx/Webservices/Registration",
        > ResponseNamespa ce:="http://xxx.xx/Webservices/Registration")> _
        > Public Function GetRegistration s(ByVal UserID As String,
        > <System.Xml.Ser ialization.Soap ElementAttribut e(DataType:="da te")>
        > ByVal
        > DateTime As Date) As
        > <System.Xml.Ser ialization.Soap ElementAttribut e("data")>
        > Object
        > Dim results() As Object = Me.Invoke("GetR egistrations", New
        > Object()
        > {UserID, DateTime})
        > Return CType(results(0 ),Object)
        > End Function
        > '<remarks/>[/color]

        Ok, the problem here is that for some reason, your proxy is only being generated
        to return data of type Object. That means that the signature of the web method
        that you're trying to call must not be too strongly typed. You said in your
        initial post that it ends up being an array of two XmlAttributes and one
        XmlElement is that right? This is very strange. Is there any way you can
        post the WSDL or a link to it? WSDL.exe normally generates much richer .NET
        method signatures than this and the fact that you're ending up with two XmlAttributes
        and an XmlElement is, once again, very strange. My guess is that the schema
        of the web method is structured such that WSDL.exe cannot make a clean translation.
        [color=blue]
        > I also don't quite known
        > how to call to 2 functions BeginGetRegistr ations and
        > EndGetRegistrat ions??[/color]

        You don't need to use those unless you want to make asynchronus calls to
        the web method. If you're interested in doing that, just let me know, and
        after we figure the main problem out I'll gladly show you how to call it.
        [color=blue]
        > In the meantime if found out that i throug a WebRequest's -
        > response.GetRes ponseStream(), get's a valid xml-document, to view in
        > Explorer.. but then i don't use the WSDL.. And i don't know how to
        > deserielize it in my vb code??[/color]

        No need to go that extreme. Worst case scenario you have the two XmlAttribtes
        and the XmlElement that represent the response message from your proxy class.
        Even it it is a little perplexing as to why it's being translated that way,
        you can still use these to access the XML data of the message.

        Cheers,
        Dre

        Comment

        • Henrik

          #5
          Re: Consuming (SOAP)webservic e in vb.net

          Hi Drew,,

          Yes, if I call the "GetRegistratin s"-function, it returns a object
          containing an array of two XmlAttributes and one XmlElement ?

          Unfortunly this is for my work, so I just can't supply you, with all
          information eg. the url to the servece,, until a have talked to my boss. :o(
          ...

          But anyhow, below is the "WSDL-definition"
          , in a littel changes format :o)

          The things i've changes:
          Is the
          url's to my service to "http://xxx.xx/Webservices/Registration"
          And som of the names,,
          But else it's idendical...


          Is this enough,, or do you whant the url to the WSDL??


          And ofcouse im interested in learning asynchronus calls to
          the web method, afterwards :o),,, You never get to old to learn something
          new :o)....


          Thanks
          Henrik


          *************** *********WSDL Definitions**** *************** *********

          <?xml version="1.0" encoding="UTF-8" ?>
          - <wsdl:definitio ns targetNamespace ="http://xxx.xx/Webservices/Registration"
          xmlns="http://schemas.xmlsoap .org/wsdl/"
          xmlns:apachesoa p="http://xml.apache.org/xml-soap"
          xmlns:impl="htt p://xxx.xx/Webservices/Registration"
          xmlns:intf="htt p://xxx.xx/Webservices/Registration"
          xmlns:soapenc=" http://schemas.xmlsoap .org/soap/encoding/"
          xmlns:wsdl="htt p://schemas.xmlsoap .org/wsdl/"
          xmlns:wsdlsoap= "http://schemas.xmlsoap .org/wsdl/soap/"
          xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
          - <wsdl:message name="GetRegist rations2Request ">
          <wsdl:part name="UserId" type="xsd:strin g" />
          <wsdl:part name="PassWord" type="xsd:strin g" />
          <wsdl:part name="DateTime" type="xsd:date" />
          <wsdl:part name="version" type="xsd:strin g" />
          </wsdl:message>
          - <wsdl:message name="GetRegist rations2Respons e">
          <wsdl:part name="data" type="xsd:anyTy pe" />
          </wsdl:message>
          - <wsdl:message name="GetRegist rationsResponse ">
          <wsdl:part name="data" type="xsd:anyTy pe" />
          </wsdl:message>
          - <wsdl:message name="GetRegist rationsRequest" >
          <wsdl:part name="UserId" type="xsd:strin g" />
          <wsdl:part name="PassWord" type="xsd:strin g" />
          <wsdl:part name="DateTime" type="xsd:date" />
          </wsdl:message>
          - <wsdl:portTyp e name="Registrat ionsPortType">
          - <wsdl:operati on name="GetRegist rations" parameterOrder= "UserId PassWord
          DateTime">
          <wsdl:input message="impl:G etRegistrations Request"
          name="GetRegist rationsRequest" />
          <wsdl:output message="impl:G etRegistrations Response"
          name="GetRegist rationsResponse " />
          </wsdl:operation>
          - <wsdl:operati on name="GetRegist rations2" parameterOrder= "UserId PassWord
          DateTime version">
          <wsdl:input message="impl:G etRegistrations 2Request"
          name="GetRegist rations2Request " />
          <wsdl:output message="impl:G etRegistrations 2Response"
          name="GetRegist rations2Respons e" />
          </wsdl:operation>
          </wsdl:portType>
          - <wsdl:binding name="Registrat ionsPortSoapBin ding"
          type="impl:Regi strationsPortTy pe">
          <wsdlsoap:bindi ng style="rpc"
          transport="http ://schemas.xmlsoap .org/soap/http" />
          - <wsdl:operati on name="GetRegist rations">
          <wsdlsoap:opera tion soapAction="" />
          - <wsdl:input name="GetRegist rationsRequest" >
          <wsdlsoap:bod y encodingStyle=" http://schemas.xmlsoap .org/soap/encoding/"
          namespace="http ://xxx.xx/Webservices/Registration" use="encoded" />
          </wsdl:input>
          - <wsdl:output name="GetRegist rationsResponse ">
          <wsdlsoap:bod y encodingStyle=" http://schemas.xmlsoap .org/soap/encoding/"
          namespace="http ://xxx.xx/Webservices/Registration" use="encoded" />
          </wsdl:output>
          </wsdl:operation>
          - <wsdl:operati on name="GetRegist rations2">
          <wsdlsoap:opera tion soapAction="" />
          - <wsdl:input name="GetRegist rations2Request ">
          <wsdlsoap:bod y encodingStyle=" http://schemas.xmlsoap .org/soap/encoding/"
          namespace="http ://xxx.xx/Webservices/Registration" use="encoded" />
          </wsdl:input>
          - <wsdl:output name="GetRegist rations2Respons e">
          <wsdlsoap:bod y encodingStyle=" http://schemas.xmlsoap .org/soap/encoding/"
          namespace="http ://xxx.xx/Webservices/Registration" use="encoded" />
          </wsdl:output>
          </wsdl:operation>
          </wsdl:binding>
          - <wsdl:service name="Registrat ions">
          - <wsdl:port binding="impl:R egistrationsPor tSoapBinding"
          name="Registrat ionsPort">
          <wsdlsoap:addre ss location="http://xxx.xx/Webservices/Registration" />
          </wsdl:port>
          </wsdl:service>
          </wsdl:definition s>

          *************** *********WSDL Definitions END************ **************


          "Drew Marsh" wrote:
          [color=blue]
          > Henrik wrote:
          >[color=green]
          > > I don't have any signature generated?? Whats that? .. The only thing
          > > i've done, is generated the WSDL from at site: eg.
          > >
          > > wsdl /language:VB /out:C:\myProxyC lass.vb
          > > http://xxx.xx/Webservices/Registration?wsdl
          > >
          > > and then loaded the "myProxyClass.v b"-file into my vb.net project, and
          > > begin using it..[/color]
          >
          > What I meant by signature was the signature of the method on your proxy class
          > that represents the web method. I just wanted to see what was generated for
          > you so I had a better idea what types you were working with. The output you
          > pasted me is exactly what I was looking for. :)
          >[color=green]
          > > <System.Web.Ser vices.Protocols .SoapRpcMethodA ttribute("",
          > > RequestNamespac e:="http://xxx.xx/Webservices/Registration",
          > > ResponseNamespa ce:="http://xxx.xx/Webservices/Registration")> _
          > > Public Function GetRegistration s(ByVal UserID As String,
          > > <System.Xml.Ser ialization.Soap ElementAttribut e(DataType:="da te")>
          > > ByVal
          > > DateTime As Date) As
          > > <System.Xml.Ser ialization.Soap ElementAttribut e("data")>
          > > Object
          > > Dim results() As Object = Me.Invoke("GetR egistrations", New
          > > Object()
          > > {UserID, DateTime})
          > > Return CType(results(0 ),Object)
          > > End Function
          > > '<remarks/>[/color]
          >
          > Ok, the problem here is that for some reason, your proxy is only being generated
          > to return data of type Object. That means that the signature of the web method
          > that you're trying to call must not be too strongly typed. You said in your
          > initial post that it ends up being an array of two XmlAttributes and one
          > XmlElement is that right? This is very strange. Is there any way you can
          > post the WSDL or a link to it? WSDL.exe normally generates much richer .NET
          > method signatures than this and the fact that you're ending up with two XmlAttributes
          > and an XmlElement is, once again, very strange. My guess is that the schema
          > of the web method is structured such that WSDL.exe cannot make a clean translation.
          >[color=green]
          > > I also don't quite known
          > > how to call to 2 functions BeginGetRegistr ations and
          > > EndGetRegistrat ions??[/color]
          >
          > You don't need to use those unless you want to make asynchronus calls to
          > the web method. If you're interested in doing that, just let me know, and
          > after we figure the main problem out I'll gladly show you how to call it.
          >[color=green]
          > > In the meantime if found out that i throug a WebRequest's -
          > > response.GetRes ponseStream(), get's a valid xml-document, to view in
          > > Explorer.. but then i don't use the WSDL.. And i don't know how to
          > > deserielize it in my vb code??[/color]
          >
          > No need to go that extreme. Worst case scenario you have the two XmlAttribtes
          > and the XmlElement that represent the response message from your proxy class.
          > Even it it is a little perplexing as to why it's being translated that way,
          > you can still use these to access the XML data of the message.
          >
          > Cheers,
          > Drew
          >
          >[/color]

          Comment

          Working...