Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 6th, 2009, 12:00 PM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP WSDL Webservice help needed... Important.

Hey all, this is kind of urgent I'm afraid...

I have to do some code where I call a wsdl file in classic ASP (I'm not happy about it but it has to be done)... I got it working with a simple hello world that returns an input string but... how do I make more advanced calls where the input parameters is complex objects?

The function I need to call is "InsertInvoiceAndCustomer". The code will be used by a company to show customers that it can be done in classic ASP.

This is the code I use for the HelloWorld function (everything works except the xmlDoc part):
Code:
'Incase web service throws an exception.
'on error resume next
 
dim objDoc, objSOAPClient
set objDoc = Server.CreateObject("Msxml2.DomDocument.4.0")
set objSOAPClient = Server.CreateObject("MSSOAP.SoapClient30")
sPath = "http://testhorizon.gothiagroup.com/AFSServices/AFSService.svc?wsdl"
objSOAPClient.ClientProperty("ServerHTTPRequest") = true
objSOAPClient.MSSoapInit(sPath)
 
if err.number <> 0 then
Response.write("<h2>Web Service Call Failed!</h2>")
else
Response.write("<h2>Web Service Call success!<br></h2>")
dim token, xmlDoc 
'Get the token
token = objSOAPClient.HelloWorld("Hello World!")
 
Response.write(token)
Response.write("<br><br>")
'Get the XML.
set xmlDoc = Server.CreateObject( "MSXML2.DomDocument" )
 
'xmlDoc.loadxml(token)
xmlDoc.loadxml("<?xml version=""1.0""?><book>text</book><library/>")
 
Response.write(xmlDoc.hasChildNodes & "<br><br>")
 
'result = xmlDoc.getElementsByTagName("Envelope/Body/HelloWorldResponse/HelloWorldResult").item(0).text
result = xmlDoc.documentElement.selectSingleNode("book")
 
Response.write(result)
end if

From a program I have called soapUI 2.5.1 I can see how the Envelope calls should look like:

This is for the HelloWorld:
Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:HelloWorld>
         <!--Optional:-->
         <tem:myValue>QQ</tem:myValue>
      </tem:HelloWorld>
   </soapenv:Body>
</soapenv:Envelope>
And this is for the InsertInvoiceAndCustomer (as you can see much more complex):
Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:hor="http://Horizon.ExternalServices" xmlns:hor1="http://Horizon.ExternalServices.AFS">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:InsertInvoiceAndCustomer>
         <!--Optional:-->
         <tem:user>
            <hor:Username>?</hor:Username>
            <hor:Password>?</hor:Password>
            <hor:ClientID>?</hor:ClientID>
         </tem:user>
         <!--Optional:-->
         <tem:customer>
            <hor1:Address>?</hor1:Address>
            <hor1:CountryCode>?</hor1:CountryCode>
            <!--Optional:-->
            <hor1:CurrencyCode>?</hor1:CurrencyCode>
            <!--Optional:-->
            <hor1:CustNo>?</hor1:CustNo>
            <hor1:CustomerCategory>?</hor1:CustomerCategory>
            <!--Optional:-->
            <hor1:DirectPhone>?</hor1:DirectPhone>
            <!--Optional:-->
            <hor1:DistributionBy>?</hor1:DistributionBy>
            <!--Optional:-->
            <hor1:DistributionType>?</hor1:DistributionType>
            <!--Optional:-->
            <hor1:Email>?</hor1:Email>
            <!--Optional:-->
            <hor1:Fax>?</hor1:Fax>
            <!--Optional:-->
            <hor1:FirstName>?</hor1:FirstName>
            <hor1:LastName>?</hor1:LastName>
            <!--Optional:-->
            <hor1:MobilePhone>?</hor1:MobilePhone>
            <!--Optional:-->
            <hor1:Organization_PersonalNo>?</hor1:Organization_PersonalNo>
            <!--Optional:-->
            <hor1:Phone>?</hor1:Phone>
            <hor1:PostalCode>?</hor1:PostalCode>
            <!--Optional:-->
            <hor1:PostalPlace>?</hor1:PostalPlace>
            <!--Optional:-->
            <hor1:StatCodeAlphaNumeric>?</hor1:StatCodeAlphaNumeric>
            <!--Optional:-->
            <hor1:StatCodeNumeric>?</hor1:StatCodeNumeric>
         </tem:customer>
         <!--Optional:-->
         <tem:invoice>
            <hor1:Amount>?</hor1:Amount>
            <!--Optional:-->
            <hor1:CashDiscountDaysToDueDate>?</hor1:CashDiscountDaysToDueDate>
            <!--Optional:-->
            <hor1:CashDiscountDueDate>?</hor1:CashDiscountDueDate>
            <!--Optional:-->
            <hor1:CashDiscountPercent>?</hor1:CashDiscountPercent>
            <!--Optional:-->
            <hor1:CashDiscountTerm>?</hor1:CashDiscountTerm>
            <!--Optional:-->
            <hor1:CrossedInvoiceNo>?</hor1:CrossedInvoiceNo>
            <!--Optional:-->
            <hor1:CurrencyAmount>?</hor1:CurrencyAmount>
            <hor1:CurrencyCode>?</hor1:CurrencyCode>
            <!--Optional:-->
            <hor1:CustNo>?</hor1:CustNo>
            <!--Optional:-->
            <hor1:DeliveryAddress>?</hor1:DeliveryAddress>
            <!--Optional:-->
            <hor1:DeliveryCity>?</hor1:DeliveryCity>
            <!--Optional:-->
            <hor1:DeliveryCountry>?</hor1:DeliveryCountry>
            <!--Optional:-->
            <hor1:DeliveryPostCode>?</hor1:DeliveryPostCode>
            <!--Optional:-->
            <hor1:DiscountProfileNo>?</hor1:DiscountProfileNo>
            <!--Optional:-->
            <hor1:DueDate>?</hor1:DueDate>
            <!--Optional:-->
            <hor1:ExchangeRate>?</hor1:ExchangeRate>
            <!--Optional:-->
            <hor1:InvoiceDate>?</hor1:InvoiceDate>
            <!--Optional:-->
            <hor1:InvoiceLines>
               <!--Zero or more repetitions:-->
               <hor1:AFSInvoiceLine>
                  <!--Optional:-->
                  <hor1:GrossAmount>?</hor1:GrossAmount>
                  <!--Optional:-->
                  <hor1:ItemDescription>?</hor1:ItemDescription>
                  <!--Optional:-->
                  <hor1:ItemID>?</hor1:ItemID>
                  <!--Optional:-->
                  <hor1:LeftText>?</hor1:LeftText>
                  <!--Optional:-->
                  <hor1:LineNumber>?</hor1:LineNumber>
                  <!--Optional:-->
                  <hor1:NetAmount>?</hor1:NetAmount>
                  <!--Optional:-->
                  <hor1:Quantity>?</hor1:Quantity>
                  <!--Optional:-->
                  <hor1:RightText>?</hor1:RightText>
                  <!--Optional:-->
                  <hor1:TaxAmount>?</hor1:TaxAmount>
                  <!--Optional:-->
                  <hor1:TaxPercent>?</hor1:TaxPercent>
                  <!--Optional:-->
                  <hor1:UnitCode>?</hor1:UnitCode>
                  <!--Optional:-->
                  <hor1:UnitPrice>?</hor1:UnitPrice>
               </hor1:AFSInvoiceLine>
            </hor1:InvoiceLines>
            <!--Optional:-->
            <hor1:InvoiceNo>?</hor1:InvoiceNo>
            <!--Optional:-->
            <hor1:InvoiceProfileNo>?</hor1:InvoiceProfileNo>
            <!--Optional:-->
            <hor1:KID>?</hor1:KID>
            <!--Optional:-->
            <hor1:NetAmount>?</hor1:NetAmount>
            <!--Optional:-->
            <hor1:Note>?</hor1:Note>
            <!--Optional:-->
            <hor1:OrderNo>?</hor1:OrderNo>
            <!--Optional:-->
            <hor1:OurRef>?</hor1:OurRef>
            <!--Optional:-->
            <hor1:StatcodeAlphaNum>?</hor1:StatcodeAlphaNum>
            <!--Optional:-->
            <hor1:StatcodeNum>?</hor1:StatcodeNum>
            <!--Optional:-->
            <hor1:VATAmount>?</hor1:VATAmount>
            <!--Optional:-->
            <hor1:YourRef>?</hor1:YourRef>
         </tem:invoice>
      </tem:InsertInvoiceAndCustomer>
   </soapenv:Body>
</soapenv:Envelope>
Can anyone help me or is there some other place where I can find someone who can?
Reply With Quote
  #2 (permalink)  
Old April 6th, 2009, 03:21 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Well, you appear to be using the Soap Toolkit, and unfortunately it's about the best thing there is for ASP usage. Have you got a decent set of docs and examples for it? If not, you should be able to find some online somewhere.

Sure you can't use ASP.NET for this one task?? ASP.NET makes calling and consuming Web services a true snap, esp. when used with Visual Studio (even the freebie Web Developer Express).
Reply With Quote
  #3 (permalink)  
Old April 6th, 2009, 04:59 PM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for answer but I have looked at alot of examples and all that I can find shows simple calls like the one I do for HelloWorld.

And unfortunately I can't use ASP.NET for this (if I could I would have been done a long time ago) because the thing is that the company wants to have an example in ASP to show for customers.
Reply With Quote
  #4 (permalink)  
Old April 7th, 2009, 02:22 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Well, for starters, in order to send a complex set of parameters, you have to encode them properly as XML. You *can* do that by hand, but MS suggests that you use the MSSOAP.SoapSerializer30 object.

Have you downloaded the MS samples, yet??
http://download.microsoft.com/downlo...t30Samples.EXE

There are several samples in there that use the Serializer to set up the needed SOAP envelope to pass along the requisite parameters.

None quite as complex as the WSDL you show there, but at least a few with nested elements, which you will need to match the required envelope.
Reply With Quote
  #5 (permalink)  
Old April 7th, 2009, 04:00 AM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have downloaded the samples and found the serializer code but those samples dosn't use wsdl.
Reply With Quote
  #6 (permalink)  
Old April 7th, 2009, 04:18 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

OH! Now I get it!

You need to have code that *AUTOMATICALLY* build the structure of the XML by inspecting the WSDL!

WOW! That's tough! Essentially, you need to duplicate all the stuff that .NET does for you. There's a .NET utility (I forget it's name) that will take the URL of a WSDL and spit out the code for a Class, and that's what you need to duplicate. WOW! Tough!

I wonder if it might be easier to run that utility and then parse the Class it outputs (does it allow you to choose C# or VB.NET class code??? I forget) into source code usable with ASP/VBScript.

Wow. This sounds like a TOUGH project. It also sounds like a fun project, and if I had the time I'd love to help, but I just don't have it right now.
Reply With Quote
  #7 (permalink)  
Old April 8th, 2009, 04:00 AM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well yes and no... that would be the best solution but really right now I just need one working way to do it in (no matter how ugly it is ).

The problem is that I thought that it would be simpler than this (got it to work in PHP) and I don't have a lot of time to put on this, got a lot of other stuff to do.
Reply With Quote
  #8 (permalink)  
Old April 8th, 2009, 04:50 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

So how did you do it in PHP?? Is there some magic toolkit for PHP as there is for ASP.NET? Or did you have to construct the SOAP XML "by hand"?

You *could* construct it "by hand" in ASP code, you know. That is, do something ugly like:
Code:
soapxml = soapheader & "<user>" & vbNewLine _
       & "<Username>" & username & "</Username><Password>" & pwd & "</Password><ClientID>" & clientid & "</ClientID>" & vbNewLine _
       & "</user>" & vbNewLine _
       ...
Reply With Quote
  #9 (permalink)  
Old April 8th, 2009, 05:51 AM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In PHP I found a a special user created library that helped alot, but that one only works with PHP...
Reply With Quote
  #10 (permalink)  
Old April 8th, 2009, 11:56 AM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have talked to the compay and they new accept ANY solution.

So... if I construct the XML "by hand" how do I send it to the webservice? I guess that I cant use the same code as before:

token = objSOAPClient.HelloWorld("Hello World!")

or can I do something like this:

strXML= ... lots of code ...
token = objSOAPClient.InsertInvoiceAndCustomer(strXML)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML - Rpc Webservice with asp.net vgsgowrisankar XML 2 April 18th, 2008 05:46 AM
Invalid char in encoding-new asp .net webservice ajcis55 C# 1 April 12th, 2007 05:42 AM
how to call webservice usin javascript in asp.net? param99 ASP.NET 1.0 and 1.1 Professional 0 January 25th, 2007 07:03 AM
wsdl.exe costaaa C# 1 August 6th, 2006 06:35 AM
WSDL Reader: Loading of the WSDL file failed. Anil .NET Web Services 0 January 23rd, 2004 02:59 PM



All times are GMT -4. The time now is 04:30 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.