function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chrisMchrisM 

Access web services from classic ASP

Is there a simple recipe to make web service calls in the classic ASP environment using MS SOAP Toolkit 3.0?

I tried the following:

dim oSOAP
set oSOAP = Server.CreateObject("MSSOAP.SoapClient")
oSOAP.ClientProperty("ServerHTTPRequest") = True
oSOAP.mssoapinit("C:\sforce.wsdl.xml")

where sforce.wsdl.xml is the WSDL file generate by sforce and saved on the local box running classic ASP and MS SOAP Tollkit 3.0.

I receive the following result:

Error Type:
Client (0x80020009)
WSDLReader:Analyzing the WSDL file failed HRESULT=0x80004005
- WSDLReader:Initialization of service failed HRESULT=0x80004005
- WSDLService:Initialization of the port for service SforceService failed HRESULT=0x80004005
- WSDLPort:Analyzing the binding information for port Soap failed HRESULT=0x80004005
- WSDLPort:An operation for port Soap could not be initialized HRESULT=0x80004005
- WSDLOperation:Initializing of the input message failed for operation delete HRESULT=0x80004005
- WSDLOperation:Initialization of a SoapMapper for operation delete failed HRESULT=0x80004005
- SoapMapper:The SoapMapper for element ids could not be created HRESULT=0x80004005

My goal is to use sforce webservices without .NET using ASP.

Thank you for any suggestions.

-Chris.
benjasikbenjasik
Check out the VB and Office Development board. You want to use the Office toolkit beta, which is a COM object you can use from classic ASP. If you install office edition, you'll get this automatically installed.
chrisMchrisM
Benji,

Does this mean that all the features of the web services API can be accessed with the Office Edition, rather than requiring the Enterprise Edition?

Also, can I access the Office Edition and related COM material via the Developer Edition so I can test out my application?

My goal is quite simple. From classic ASP I would like to search for a contact by a specif ic field and then retrieve another field or fields for that contact if a match is found. The field(s) I need returned are custom fields added to the base contact table.

Thank you,
Chris.
benjasikbenjasik
API access is still limited to EE and DE orgs.

Once you download the office toolkit (A COM object that is currently in beta, and included with office edition), you can use this object to access the site, but you don't have to worry about any WSDLs, webservices, etc. It handles all of that for you.

You can search and retrieve using the office toolkit COM object. The documentation is sparse (you'll need to read the boards), but I think it's exactly what you want.
chrisMchrisM
Benji,

Thank you for the quick response. I have installed the Office Edition and tested the sample Excel macros. You weren't kidding about documentation being sparse!

After reviewing a lot of the message boards, I was unable to find a simple, clear example of using SF_MSApi.dll in ASP (either VBScript or JScript) to login and run a simple query. Is there such an example? It would make all very clear.

I did find some examples of folks pushing hand crafted SOAP messages as well as using PocketSOAP. Do you recommend either of these routes?

Lastly, just to clarify, do I understand correctly that the Office Edition DLL will only access EE or DE accounts?

Thank you again,
Chris.
DevAngelDevAngel

Hi chrisM,

All API use is restricted to EE and DE, with one exception.  The exception is for a certified Partner solution.  These solutions can run against PE as well.

 

As to sample code, let me poke around my toybox and see if I can dig one up for you.

DevAngelDevAngel

Hi chrisM,

I dug up an old sample that shows using the toolkit from VBScript on an asp page as well as some server side use on an asp page.

When using the link below, right-click and use save as.

Message Edited by DevAngel on 12-01-2004 11:40 AM

chrisMchrisM
Dave,

In the meantime, I've experimented with hand-coded SOAP per some other messages on the boards. I can successfully login, but am having trouble with a version error on sending a search command. Any ideas?

Here's the code...

strUsername = "[username]"
strPassword = "[password]"
sforceSoapServer = "https://www.salesforce.com/servlet/servlet.SoapApi"

sforceSoapHeader = " & " xmlns:tns=""salesforce"" xmlns:types=""salesforce/encodedTypes"" "_
& " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "_
& " xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> " _
& " soap-env:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""> " _
& " " _
& " "

sforceSoapFooter = ""

strSoapBody = " "
strSoapBody = strSoapBody & ""
strSoapBody = strSoapBody & "2.0"
strSoapBody = strSoapBody & "" & strUsername & ""
strSoapBody = strSoapBody & "" & strPassword & ""
strSoapBody = strSoapBody & ""
strSoapBody = strSoapBody & ""

strSoapRequest = sforceSoapHeader & strSoapBody & sforceSoapFooter

'Build the SOAP header
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "POST", sforceSoapServer , False 'False = do not respond immediately
xmlhttp.setRequestHeader "Man", POST & " " & sforceSoapServer & " HTTP/1.1"
xmlhttp.setRequestHeader "Content-Type", "text/xml"

'Send the SOAP request
xmlhttp.send(strSoapRequest)

'Display result
Set xmlDOM = xmlhttp.responseXML

Set strServer = xmlDOM.documentElement.selectSingleNode("//server_url")
Set strSession = xmlDOM.documentElement.selectSingleNode("//session_id")

The above does a successful login that returns a server url and a session id. I use this info to attempt a simple search of contact on the DE.

sforceSoapServer = strServer.text

sforceSoapHeader = " & " xmlns:tns=""salesforce"" xmlns:types=""salesforce/encodedTypes"" "_
& " xmlns:sforce=""urn:enterprise.soap.sforce.com"" "_
& " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "_
& " xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> " _
& " soap-env:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""> " _
& " " _
& " 2.0 " _
& " " _
& " uejMEgecf8yidA3jXlNKOSU " _
& " " _
& " "

sforceSoapFooter = ""

strSoapBody = " "
strSoapBody = strSoapBody & ""
strSoapBody = strSoapBody & "find {jflynn@ups.com} in email returning contact(id, firstname, lastname, password)"
strSoapBody = strSoapBody & ""
strSoapBody = strSoapBody & ""

strSoapRequest = sforceSoapHeader & strSoapBody & sforceSoapFooter

'Build the SOAP header
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "POST", sforceSoapServer , False 'False = do not respond immediately
xmlhttp.setRequestHeader "Man", POST & " " & sforceSoapServer & " HTTP/1.1"
xmlhttp.setRequestHeader "Content-Type", "text/xml"

'Send the SOAP request
xmlhttp.send(strSoapRequest)

'Display result
Set xmlDOM = xmlhttp.responseXML
Response.Write("" & xmlDOM.xml & "

")

The response XML is...

0version not specified

How do I deal with the version not specified fault?

Thanks,
Chris.
DevAngelDevAngel

Chris,

This is absolutely the wrong thing to do.  2.0 of our soap implementation was very, very bad.  Basically, a soap wrapper around the xml-rpc api.

Check out the sample that I posted earlier.

chrisMchrisM
Dave,

The target environment for my project is a shared hosted server on which I cannot install custom DLLs. That's why I'm trying SOAP. The beauty of SOAP is that its an open HTTP-based protocol. On Windows, all you need is MSXML. As long as I understand the message formats for the sforce endpoint, I'm hoping I can make the connection work (login already seems to work).

The only method (other than login) I need is an SOSL search. Specifically,

find {[emailaddr]} in email returning contact(id, firstname, lastname)

Is this possible with sforce?

Thanks,
Chris.
DevAngelDevAngel

Hi Chris,

Yup, ok, I understand.  Yes, it is possible.  Here is a sample.

chrisMchrisM
Dave,

I did get a valid SOAP dialog going using the version 2.0 documentation from the Resources section of the sforce site. The only piece I'm missing now is the ability to retrieve custom fields. I added a customer field called Test and attempted to access it via Test, test, Test_c, Test__c, cf_Test, cf__Text. None of these work.

Here's the SOAP snippet (a small modification from the examples inthe 2.0 docs):

& " " _
& " " _
& " contact " _
& " filter " _
& " 20 " _
& " " _
& " " _
& " " _
& " " _
& " lastName " _
& " firstName " _
& " id " _
& " test " _
& " " _
& " " _
& " " _
& " " _
& " " _
& " " _
& " " _
& " " _
& " " _
& " " _
& " field " _
& " email " _
& " " _
& " " _
& " value " _
& " " & Request.Form("uname") & " " _
& " " _
& " " _
& " operator " _
& " contains " _
& " " _
& " " _
chrisMchrisM
looks like the previous post got munged by lithium.
chrisMchrisM
Dave,

This sample returns a faultcode of ns1:Client.NoSOAPAction. Any ideas?

-Chris.
chrisMchrisM
Dave,

I missed the [setRequestHeader "SOAPaction", "login"] line in your sample. Once added, all is working, including access to my custom fields (which apparently the older 2.0 version is not too happy about).

Thank you very much for your patience and help.

-Chris.
DevAngelDevAngel

Hi Chris,

The 2.0 version did not use friendly names for custom fields and had a myriad of other issues.  Stay away from that version like the plague!

JamesNJamesN

Hi Dave,

Would it be possible for you to send me some sample code so get me started?  I am currently using asp and need a way to talk to web services , soap.  Any working example to get me up and running is appreciated.

Thanks
James

needdevhelpneeddevhelp
It looks like this thread has previously answered all of my quetsions, but none of the link to example code seem to be there.  I can't find them anyway.  Could you repost the sample code that was mentioned in this thread?
 
Thanks
accelbridgeaccelbridge

It looks like the sample mentioned has been ... er ... redacted.

Can anyone help me get this sample code?

Thx

accelbridgeaccelbridge
Thanks.  This works well.
 
Right now, though, I already have a sessionid, so I don't think I need to login, but to query I also need the server url.
 
Is there another way to get this without logging in? 
SuperfellSuperfell
If you got your sessionId from a merge field, there are also merge fields for serverUrls
ColdfingerColdfinger

 Hi, I've tried using the link that SimonF posted above.  I've amended with the username/password of an API enabled user, with the password appending the security token as from the instructions in the guide it should do,

I've also updated the soap version to what I believe to be the current one Soap/u/16.0

 

however when calling xmlhttp.send(  with the login request, it is failing, the message given is:

 

msxml3.dll error '800c0005'

The system cannot locate the resource specified.

 

I admit I'm a bit green on this subject, does anyone have any suggestions as to what I am doing wrong?

 

Thanks in advance