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:
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?