How to create a proxy class without a WSDL document?

Discussion in 'ASP .Net Web Services' started by Attila, Dec 9, 2003.

  1. Attila

    Attila Guest

    Hello,

    I'm new to web services, so please forgive my ignorance. I need to
    create an interface with a third party Web Service. From what I
    understand about Web Services, I need to create a proxy class that
    will let me call the Web Methods that are expose by the third party's
    Web Service. However, the third party doesn't provide a WSDL document.
    What they do provide in their documentation is the names of the
    available "transactions" (which I assume is their word for Web
    Methods), and also DTD's that are used by the transactions.
    If I'm correct in that I need to create a proxy class, how would I
    be able to do this without a WSDL document? Should I be able to do
    this with just the method names, and the DTDs?
    Any help would be much appreciated.

    Thanks,
    Attila
     
    Attila, Dec 9, 2003
    #1
    1. Advertising

  2. Hey Attila,
    What's the third party?
    What is the web services stack they use?
    Can you show us the documentation?

    All current, compliant web services stacks do WSDL. It is one of the
    primary interop standards for web services.

    Could it be that this third party does not actually expose web services at
    all, but instead exposes a REST-ful XML interface ? In which case you
    wouldn't need to use a WSDL and a generated proxy, but you'd need to send
    XML docs of a well known format (Defined by the DTDs) to corresponding HTTP
    endpoints. ? Or could it be XML-RPC ? In which case you'd need an XML-RPC
    stack for .NET (there is at least one 3rd party implementation).

    If not, then you could try to reverse-engineer the service and independently
    construct your own WSDL, which would correspond to the wsdl-less service you
    have, then generate a proxy from it. Start by converting the DTDs to XML
    schema. Then, to zero in on the WSDL you may need to iterate over WSDL
    designs and the messages each version generates. You can use wsdl /server
    to generate a server stub corresponding to a given wsdl - this will give you
    something to invoke against while iterating. Also check out proxytrace,
    which will let you examine your xml messages on the wire.

    -Dino



    "Attila" <> wrote in message
    news:...
    > Hello,
    >
    > I'm new to web services, so please forgive my ignorance. I need to
    > create an interface with a third party Web Service. From what I
    > understand about Web Services, I need to create a proxy class that
    > will let me call the Web Methods that are expose by the third party's
    > Web Service. However, the third party doesn't provide a WSDL document.
    > What they do provide in their documentation is the names of the
    > available "transactions" (which I assume is their word for Web
    > Methods), and also DTD's that are used by the transactions.
    > If I'm correct in that I need to create a proxy class, how would I
    > be able to do this without a WSDL document? Should I be able to do
    > this with just the method names, and the DTDs?
    > Any help would be much appreciated.
    >
    > Thanks,
    > Attila
     
    Dino Chiesa [Microsoft], Dec 9, 2003
    #2
    1. Advertising

  3. Attila

    Attila Guest

    Thank you for your response. I recently contacted the third parties
    technical support, and their response was "our interface is not a .NET
    web service." Their documentation states "The XML Gateway supports
    HTTPS post transactions using the XML -based file types." Originally,
    I thought that sending XML over HTTP was considered a Web Service,
    although this appears to not be the case.
    Given that, I'm not sure how to proceed. Any there any MSDN
    articles that you think would be helpful?

    Thanks,
    Attila


    "Dino Chiesa [Microsoft]" <> wrote in message news:<>...
    > Hey Attila,
    > What's the third party?
    > What is the web services stack they use?
    > Can you show us the documentation?
    >
    > All current, compliant web services stacks do WSDL. It is one of the
    > primary interop standards for web services.
    >
    > Could it be that this third party does not actually expose web services at
    > all, but instead exposes a REST-ful XML interface ? In which case you
    > wouldn't need to use a WSDL and a generated proxy, but you'd need to send
    > XML docs of a well known format (Defined by the DTDs) to corresponding HTTP
    > endpoints. ? Or could it be XML-RPC ? In which case you'd need an XML-RPC
    > stack for .NET (there is at least one 3rd party implementation).
    >
    > If not, then you could try to reverse-engineer the service and independently
    > construct your own WSDL, which would correspond to the wsdl-less service you
    > have, then generate a proxy from it. Start by converting the DTDs to XML
    > schema. Then, to zero in on the WSDL you may need to iterate over WSDL
    > designs and the messages each version generates. You can use wsdl /server
    > to generate a server stub corresponding to a given wsdl - this will give you
    > something to invoke against while iterating. Also check out proxytrace,
    > which will let you examine your xml messages on the wire.
    >
    > -Dino
    >
    >
    >
    > "Attila" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I'm new to web services, so please forgive my ignorance. I need to
    > > create an interface with a third party Web Service. From what I
    > > understand about Web Services, I need to create a proxy class that
    > > will let me call the Web Methods that are expose by the third party's
    > > Web Service. However, the third party doesn't provide a WSDL document.
    > > What they do provide in their documentation is the names of the
    > > available "transactions" (which I assume is their word for Web
    > > Methods), and also DTD's that are used by the transactions.
    > > If I'm correct in that I need to create a proxy class, how would I
    > > be able to do this without a WSDL document? Should I be able to do
    > > this with just the method names, and the DTDs?
    > > Any help would be much appreciated.
    > >
    > > Thanks,
    > > Attila
     
    Attila, Dec 10, 2003
    #3
  4. Attila, I would agree, XML over HTTP is not web services. But still a
    useful mechanism. REST-ful.

    If you want to programmatically make an HTTP Post from within an app, then
    try something like

    private static string PostURI(string URI, string Parameters)
    {
    string CommandURI = URI;
    WebRequest myWebRequest = WebRequest.Create(CommandURI);

    //needed only if outbound traffic must go through a proxy server
    //WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
    //myWebRequest.Proxy = proxyObject;

    myWebRequest.ContentType = "application/x-www-form-urlencoded";
    myWebRequest.Method = "POST";
    byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
    myWebRequest.ContentLength = bytes.Length;
    Stream OutputStream = myWebRequest.GetRequestStream ();
    OutputStream.Write (bytes, 0, bytes.Length);
    OutputStream.Close ();
    WebResponse MyWebResponse = myWebRequest.GetResponse();
    Stream MyStream = MyWebResponse.GetResponseStream();
    StreamReader MyStreamReader = new StreamReader(MyStream);
    return MyStreamReader.ReadToEnd().Trim();
    }

    and call it like so:
    String result= PostURI("https://server/whatever",
    "arg1=7&arg2=42&arg3=Dino");


    This approach (XML over HTTP) doesn't give you webservices goodness, like a
    WSDL file that defines the interface, a tool that translates the interface
    into platform-specific type definitions and request proxy classes (eg,
    wsdl.exe). In other words, it's up to your app to make sure you are
    sending the right request and parsing the response properly. There are
    some pieces of .NET that may help, for example xsd.exe and the xml
    serialization classes.

    If you know the schema of the response you can generate a type corresponding
    to that schema like so:
    xsd.exe /c schema.xsd

    Then you can instantiate that generated type from the returned string, by
    using XML serialization and a StringReader. Like so:

    System.Xml.Serialization.XmlSerializer s = new
    System.Xml.Serialization.XmlSerializer(typeof(MyGeneratedType));
    System.IO.StringReader sr = new
    System.IO.StringReader(returnedString);
    MyGeneratedType instance = s.Deserialize(sr);


    -D





    "Attila" <> wrote in message
    news:...
    > Thank you for your response. I recently contacted the third parties
    > technical support, and their response was "our interface is not a .NET
    > web service." Their documentation states "The XML Gateway supports
    > HTTPS post transactions using the XML -based file types." Originally,
    > I thought that sending XML over HTTP was considered a Web Service,
    > although this appears to not be the case.
    > Given that, I'm not sure how to proceed. Any there any MSDN
    > articles that you think would be helpful?
    >
    > Thanks,
    > Attila
    >
     
    Dino Chiesa [Microsoft], Dec 10, 2003
    #4
  5. Attila

    Attila Guest

    I must be missing something. The request that I send to the third
    party is also supposed to be XML. I'm not sure that I can send the
    parameters as you suggest.

    I did create a class file, based on the request DTD, using the xsd.exe
    tool. However, while I was able to create an object based on the
    class, none of the properties (XML elements) were available to me.
    When I view the class in the object browser it shows the properties,
    but I get a compilation error when I try to access the properties in
    my code. I'm not sure what the problem is.

    Attila



    "Dino Chiesa [Microsoft]" <> wrote in message news:<#>...
    > Attila, I would agree, XML over HTTP is not web services. But still a
    > useful mechanism. REST-ful.
    >
    > If you want to programmatically make an HTTP Post from within an app, then
    > try something like
    >
    > private static string PostURI(string URI, string Parameters)
    > {
    > string CommandURI = URI;
    > WebRequest myWebRequest = WebRequest.Create(CommandURI);
    >
    > //needed only if outbound traffic must go through a proxy server
    > //WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
    > //myWebRequest.Proxy = proxyObject;
    >
    > myWebRequest.ContentType = "application/x-www-form-urlencoded";
    > myWebRequest.Method = "POST";
    > byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
    > myWebRequest.ContentLength = bytes.Length;
    > Stream OutputStream = myWebRequest.GetRequestStream ();
    > OutputStream.Write (bytes, 0, bytes.Length);
    > OutputStream.Close ();
    > WebResponse MyWebResponse = myWebRequest.GetResponse();
    > Stream MyStream = MyWebResponse.GetResponseStream();
    > StreamReader MyStreamReader = new StreamReader(MyStream);
    > return MyStreamReader.ReadToEnd().Trim();
    > }
    >
    > and call it like so:
    > String result= PostURI("https://server/whatever",
    > "arg1=7&arg2=42&arg3=Dino");
    >
    >
    > This approach (XML over HTTP) doesn't give you webservices goodness, like a
    > WSDL file that defines the interface, a tool that translates the interface
    > into platform-specific type definitions and request proxy classes (eg,
    > wsdl.exe). In other words, it's up to your app to make sure you are
    > sending the right request and parsing the response properly. There are
    > some pieces of .NET that may help, for example xsd.exe and the xml
    > serialization classes.
    >
    > If you know the schema of the response you can generate a type corresponding
    > to that schema like so:
    > xsd.exe /c schema.xsd
    >
    > Then you can instantiate that generated type from the returned string, by
    > using XML serialization and a StringReader. Like so:
    >
    > System.Xml.Serialization.XmlSerializer s = new
    > System.Xml.Serialization.XmlSerializer(typeof(MyGeneratedType));
    > System.IO.StringReader sr = new
    > System.IO.StringReader(returnedString);
    > MyGeneratedType instance = s.Deserialize(sr);
    >
    >
    > -D
     
    Attila, Dec 12, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. amine
    Replies:
    0
    Views:
    398
    amine
    Oct 19, 2003
  2. news.microsoft.com
    Replies:
    0
    Views:
    458
    news.microsoft.com
    Apr 12, 2006
  3. Francisco Garcia
    Replies:
    2
    Views:
    495
    Fran Garcia
    Apr 13, 2006
  4. Mike Dinnis

    WSDL.exe doesn't seem to create the proxy class

    Mike Dinnis, Oct 28, 2003, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    243
    Mike Dinnis
    Nov 3, 2003
  5. RH
    Replies:
    1
    Views:
    284
    Dino Chiesa [Microsoft]
    May 27, 2004
Loading...

Share This Page