Results 1 to 17 of 17

Thread: [2005] Web Service consuming another Web Service

  1. #1

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Exclamation [2005] Web Service consuming another Web Service

    Hi,

    I'm building a Web Service which calls another Web Service (SOAP 1.1, POST Method).
    I've found several examples like this one but it seems I need a web form to post the data.

    It does work in a regular ASP.NET site but not in a Web Service project.

    Thanks for any good input.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    In Solution Explorer, right click the project, add web reference.

    Give it the URL of your web service (the client is not concerned with what the web service does or if it actually calls a database or another web service).

    Declare an object using the namespace/classes provided by the web reference.

    Use any method to call the method.


    Right, so that's how you'd post the data.

    I don't know what you mean by it not working in a web service project. You'll need to explain.

  3. #3

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Exclamation Re: [2005] Web Service consuming another Web Service

    Quote Originally Posted by mendhak
    In Solution Explorer, right click the project, add web reference.

    Give it the URL of your web service (the client is not concerned with what the web service does or if it actually calls a database or another web service).

    Declare an object using the namespace/classes provided by the web reference.

    Use any method to call the method.


    Right, so that's how you'd post the data.

    I don't know what you mean by it not working in a web service project. You'll need to explain.
    Thanks but this don't work.
    I can't add the Web Service in the Web References because it has no WSDL.
    This Web Service can be tested using Firefox's Plug-in Poster.

    The only way is to mimic a form and submit it using POST method.

    How to do it in a Web Service project?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    What sort of a web service is it then? If it is not SOAP, is it a REST service? WCF?

  5. #5

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    It is a SOAP 1.1 using POST Method but it don't have a WSDL so I can't make a Web Reference in my Web Service Project.
    I'm still a newbie in Web Services.

    Thanks.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    If it's SOAP then you do have a WSDL.

    If you are unable to add a webreference from WebServiceProject1 to WebServiceProject2, then you need to use the wsdl.exe utility to get the 'references'. To do this, you'd use it something like

    wsdl.exe http://pathtowebservice2/

    And specify additional parameters. These additional parameters will let you define the language (C# or VB.NET) as well as the location where the class files should be written.

    Once you have obtained the class file, add it to your project and start using it.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service


  8. #8

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    It has no WSDL, I've got only a .doc file what should be the XML data I need to POST.
    Is it possible to use this file to create a WSDL?

    I've already tried this but still no luck.

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    I'm afraid there's a slight (big) gap in understanding here... can we have a look at this DOC file?

  10. #10

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    Quote Originally Posted by mendhak
    I'm afraid there's a slight (big) gap in understanding here... can we have a look at this DOC file?
    I'm sorry but I don't have the files here, I left it in our office.
    Anyway, it contains only sample XML data that I need to send to our partner's Web Service URL.

    Like this:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?/>
    <SOAP-ENV:Envelope
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

    <SOAP-ENV:Body>
    <m:NDFDgenByDayRequest xmlns:SOAPSDK1="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl">
    <latitude xsi:type="xsd:decimal">33.955464</latitude>
    <longitude xsi:type="xsd:decimal">-83.383245</longitude>
    <startDate xsi:type="xsd:date"></startDate>
    <numDays xsi:type="xsd:integer">1</numDays>
    <format>24 Hourly</format>
    </m:NDFDgenByDayRequest>
    </SOAP-ENV:Body>

    </SOAP-ENV:Envelope>
    I've managed to send these XML data through WebRequest class and get the result through WebResponse class.
    The response is in String data type but in XML(SOAP) format and I'm trying to convert it to an XML data object to extract the contents properly.
    Is there a SOAP parser in C#?

    Thanks.

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    When you receive the response, you can get it out as a string and then load it into an XmlDocument object by setting the .InnerXml property.

    vb Code:
    1. Dim doc As New XmlDocument()
    2. doc.InnerXml = yourResponseString

    Assuming you're getting XML back as a response... well there you go.

    Looking at your XML, I'm wondering about this

    Code:
    http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl
    Is that the web service you're connecting to? You can easily generate a proxy/reference class from that using wsdl.exe or simply add a reference to it.


    You also have the option of looking at the SoapFormatter class and the SoapFormatter.Deserialize method:

    http://msdn.microsoft.com/en-us/libr...ze(VS.71).aspx

  12. #12

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    Thanks.
    I'll try it tomorrow.

    Is that the web service you're connecting to? You can easily generate a proxy/reference class from that using wsdl.exe or simply add a reference to it.


    You also have the option of looking at the SoapFormatter class and the SoapFormatter.Deserialize method:

    http://msdn.microsoft.com/en-us/libr...ze(VS.71).aspx
    I'm sorry but it is not the Web Service I need to consume, I've just found that as a sample in WikiBooks about SOAP.
    But this kind of XML element is not present in any of the samples I've got from our partner.
    <m:NDFDgenByDayRequest xmlns:SOAPSDK1="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl">

  13. #13
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    Ah, apologies. Yes, do try those out, let us know.

  14. #14

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    Thanks.

    I'm thinking of moving this project to a more powerful application.

    Maybe I'll create another thread about this.

  15. #15

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    The adding of Web Reference should be avoided in this project.
    I need to make this application to send SOAP data dynamically through loading URLs and SOAP Templates from files.
    If we got new partners; we don't need to turn-off this app, re-write it, then re-deploy.

    Thanks.

  16. #16
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Web Service consuming another Web Service

    If you get new partners, will the SOAP envelope/body change or will it stay the same?

  17. #17

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Web Service consuming another Web Service

    It will change but I'm thinking of creating multiple XML file templates for every partner so there would be no downtime or re-coding.
    It will become dynamic and database-driver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width