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
TebodaTeboda 

Error 500 when calling my Webservice from an s-control

Hi all. 

 

I'm trying to implement a web service (hosted on one of our companies web servers) that can be called from Salesforce to receive license information from our licensing system that should then be stored in SalesForce. So, this is a webservice called from within SalesForce and not the other way around (which judging by the examples I found seems to be the the most common case).

 

At first I was getting javescript errors due to no sessionId being set for sforce.connection (?) which I was able to debug in Visual Studio. This was resolved by adding a call to sforce.connection.login however I am still getting a http error 500 on the call. It works perfectly fine if called by performing a POST from a stand-alone HTML-page but not from within Salesforce. Am I missing some vital step? Here's my test S-control which requests a specific serial number from the webservice:

 

 

<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>

<script type="text/javascript">

sforce.connection.login("john.doe@somecompany.com", "passwordSECURITYTOKEN");

function GetWsSn(){

var envelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +

' xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +

' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ' +

' <soap:Body> ' +

' <Generate xmlns="http://MyXMLWebServiceNameSpace/"> ' +

' <outSN></outSN> ' +

' <inCountry>1</inCountry> ' +

' <inPartner>1</inPartner> ' +

' <inCount>1</inCount> ' +

' <inPrefix>NSS</inPrefix> ' +

' </Generate> ' +

' </soap:Body> ';

var request = null;sforce.connection.remoteFunction({

url : "http://85.226.44.189/northernweblicex/SerialNumber.asmx",

requestHeaders: {

"Content-Type": "text/xml; charset=utf-8",

"SOAPAction": "http://NorthernWebLicEx.northern.net/Generate"

},

mimeType: "text/xml",

requestData: envelope,

method: "POST",

onSuccess : function(response, _request) {

document.getElementById("result").value = response.GenerateResult;

},

onFailure : function(response, request) {

document.getElementById("result").value = "Failed " + response + "\n" + request.getAllResponseHeaders();

}

});

}</script>

<body>

Country 1 <select id="country1"></select>

Country 2 <select id="country2"></select>

<input type="button" value="Get Rate" onclick="javascript&colon; GetWsSn();" />

<br><br>Results<br>

<textarea rows="10" id="result" cols="80"></textarea>

</body>

 

 

 

Message Edited by Teboda on 04-20-2009 02:04 AM
TebodaTeboda

Some more info:

 

- The site hosting the webservice has been added to the remote site list under security settings.

werewolfwerewolf
A 500 error usually indicates a server error -- are you sure your webservice is getting what you think you're sending it?