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
NewToSFNewToSF 

calling apex generated Webservice in s-control

Hi,
 
  I have webservice written in .net located on my machine (I could see the web page located in same directory from URL type s-control in salesforce. so that means salesforce can access the files from that directory.)  I generated APex class from the WSDL(had to remove soap12 bindings).
 
//Generated by wsdl2apex
public class tempuriOrg {
    public class HelloWorld_element {
        public String arg;
        private String[] arg_type_info = new String[]{'arg','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
        private String[] field_order_type_info = new String[]{'arg'};
    }
    public class testSalesForceSoap {
        public String endpoint_x = 'http://machineName/virtualdirectoryname/testSalesForce.asmx';
        private String[] ns_map_type_info = new String[]{'http://tempuri.org/', 'tempuriOrg'};
        public String HelloWorld(String arg) {
            tempuriOrg.HelloWorld_element request_x = new tempuriOrg.HelloWorld_element();
            tempuriOrg.HelloWorldResponse_element response_x;
            request_x.arg = arg;
            Map<String, tempuriOrg.HelloWorldResponse_element> response_map_x = new Map<String, tempuriOrg.HelloWorldResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/HelloWorld',
              'http://tempuri.org/',
              'HelloWorld',
              'http://tempuri.org/',
              'HelloWorldResponse',
              'tempuriOrg.HelloWorldResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.HelloWorldResult;
        }
    }
    public class HelloWorldResponse_element {
        public String HelloWorldResult;
        private String[] HelloWorldResult_type_info = new String[]{'HelloWorldResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
        private String[] field_order_type_info = new String[]{'HelloWorldResult'};
    }
}
 
 
then I wrote wrapper apex class to call the apex code generated.
 
global class testSalesforce{
WebService static string test1(string name) {
tempuriOrg.testSalesForceSoap soap = new tempuriOrg.testSalesForceSoap();
return soap.HelloWorld('hello world !!! ' + name);}}
 
Then I created s-control to call this new webservice.
 
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>
<script src="/soap/ajax/10.0/apex.js"></script>
<script>
function X() {
try{
var result = sforce.apex.execute("testSalesforce" ,"test1", {arg:" hello"});
}
 catch (ex)
      {
       alert ("Failed : " + ex);
      }
}
</script>
</head>
<body onload=X()>
 <div id=userNameArea></div>
</body>
</html>
 
In security controls/remote site settings I have http://machinename url provided.
 
I am invoking the s-control on custom button click. when I give machinename in endpoint_x, I am getting:
System.CalloutException: Web service
    callout failed: Unexpected element. Parser was expecting element
    'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
 
and when I give ip address in endpoint_x and remote site settings I am getting :
IO Exception: Read Timed out
 
What do I need to do to get it working?
 
Thanks,


Message Edited by NewToSF on 04-01-2008 11:52 AM
Best Answer chosen by Admin (Salesforce Developers) 
Maddy123Maddy123
Hi

     I also want to put my Web sevice on public server but have very little idea about that.
And not able to access Web Service from  client machine.

Would you like to help me in order to know the steps to follow to do same.

Thanks in advance.

All Answers

cheenathcheenath
Is your machine accessable from sfdc servers? It seems that is the problem.
If you tell me what your machine name/ipaddress is, I will be able to check.


NewToSFNewToSF
cheenath,
 
  I am already using another s-control which has a url redirecting to my machine. and it's displaying page correctly in iframe in sfdc. Doesn't it prove that sfdc servers can access my machine?
And if I have to send you my machine name or ip address how can I send it? I don't want to post it here.
 
Thanks,
SuperfellSuperfell
All the s-control proves is that your browser can reach your server, not that salesforce can reach your server.
cheenathcheenath
I am not able to ping your server.

You can check it for userself using this site:

http://network-tools.com/default.asp?prog=ping&host=


NewToSFNewToSF
How can I make my developers machine accessible from sfdc servers? Is there going to be one server accessing my machine? Netwrok admin says we can't do it unless we have specific information about from where request is coming?
How do you generally do it for developers to test?
NewToSFNewToSF
I put my webservice on public server and it worked.thanks for the help.
asdfgasdfg
Hello everybody
                 I have two doubts and would require your help and expertise on that.
1. Can a class with webservice methods be invoked using a trigger.
2. 
Is there any other way that we can deploy a web service such that it is accessible by Salesforce, other then the Global  IP way.
Code:
global class NewAccounts
 {
 global class AccountInfo 
  {
  WebService String AccountName;
  WebService String AccountExternalId;
  }
 WebService static Account CreateAccount(AccountInfo info) 
  {
  Account acct = new Account();
  acct.Name = info.AccountName;
  acct.External_Id__c = info.AccountExternalId;
  Insert acct;
  return acct;
  }
 WebService static Account UpdateAccount(AccountInfo info) 
  {
  Account acct = new Account();
  acct.External_Id__c = info.AccountExternalId;
  Update acct;
  return acct;
  }
 }

In the above code, I have written a class to create a Account and Update a account, but i am  clueless to test the webservice.

can anyone can help me with this

Many Thanks in Advance.
Angel
 

Maddy123Maddy123
Hi

     I also want to put my Web sevice on public server but have very little idea about that.
And not able to access Web Service from  client machine.

Would you like to help me in order to know the steps to follow to do same.

Thanks in advance.
This was selected as the best answer
sasasasa
Angel, try cheenath's tutorial http://cheenath.com/?tutorial/sfdc/sample1/index.html
sasasasa
hi Guys,

        I have the a slightly different issue but the same error with this.

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Body>
   <soapenv:Fault>
     <faultcode>soapenv:Client</faultcode>
     <faultstring>System.CalloutException: IO Exception: Read timed out
Class.placeOrderSubject: line 151, column 13
Class.placeOrder: line 65, column 20</faultstring></soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

        The issue is, the server did return a response but slow. and SF's side timed out before we could recieve the response and treat it as a failed case.

        Any solution to increase the callout timeout limit?

        any advise is appreciated.

thks!
Lynn