+ Start a Discussion
CloudGeekCloudGeek 

Apex Callout Error : Access Denied though the remote site settings done and also request header has Uname and pswd

Hi,

I am trying to make a callout to a Siebel Web Service to send the account created.

Here is what I did so far :
1. Generated the Classes from WSDL received from Siebel
2. Remote Site Setting Maintained with the URL ( http://192.168.XX.XX/SOME_PATH)
3. Created sample VF page for account Creation
4. Controller is implemented to perform call out with a @future Method
5. In the @future method, which is doing the callout actually, I have provided the access parameters for auth in the header like shown in the below code :

Still I am wondering why would this callout failed ?

Please suggest me what would have been missed or any workaround to get this resolved ?

Code of Controller :

public with sharing class calloutAccount {

    public Account account { get; private set; } 

    public calloutAccount(ApexPages.StandardController controller) 
    {
        Id id = ApexPages.currentPage().getParameters().get('id');
        account = (id == null)? new Account() : [SELECT Name, AccountNumber, Account_Status__c FROM Account WHERE Id = :id];
    }
    
    public PageReference saveAccount() 
    {
        try 
        {
            upsert(account);
        } 
        catch(System.DMLException e) 
        {
            ApexPages.addMessages(e);
            return null;
        }
        //  After successful Save, navigate to the default view page
        PageReference redirectSuccess = new ApexPages.StandardController(Account).view();         
                           
        DoCallout(account.Id,account.Account_Status__c);       
            
        return (redirectSuccess);
    }
    
    public PageReference cancelAccount() 
    {
        //  After Cancel, navigate to the default view page
        PageReference redirectSuccess = new ApexPages.StandardController(Account).view();
        return (redirectSuccess);
    }
    
    @future(callout=true)
        private static void DoCallout(Id actID,String actStatus)
        {   
            Account account = [SELECT Name,AccountNumber,Account_Status__c FROM Account WHERE Id =: actID];  //Query for the inserted account ABOVE
                
            System.debug(' @@@ acccount ID from FUTURE menthos() = '+ account.Id);
                                       
                string UName = 'username'; 
                string Passwd = 'password';                             
                string SoapXMLBody;
    
SoapXMLBody = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asi="http://siebel.com/asi/" xmlns:acc="http://www.siebel.com/xml/Account%20Interface"> <soapenv:Header> <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"> http://schemas.xmlsoap.org/ws/2002/07/secext <wsse:UsernameToken xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"> <wsse:Username>'+ UName + '</wsse:Username> <wsse:Password Type="wsse:PasswordText">' + Passwd + '</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <asi:SiebelAccountSynchronize_Input> <acc:ListOfAccountInterface> <!--Zero or more repetitions:--> <acc:Account operation="insert"> <!--Optional:--> <acc:AccountId>' + account.AccountNumber + '</acc:AccountId> <acc:AccountStatus>' + account.Account_Status__c + '</acc:AccountStatus> <acc:Name>' + account.name + '</acc:Name> </acc:Account> </acc:ListOfAccountInterface> </asi:SiebelAccountSynchronize_Input> </soapenv:Body> </soapenv:Envelope>' ;                
 
               System.debug('@@@ SoapXMLBody = '+SoapXMLBody);
               
                            string SoapXML; 
                            SoapXML = SoapXMLBody; 
                            Integer ContentLength = 0; 
                            ContentLength = SoapXML.length(); 
                            
                            Http h = new Http(); 
                            HttpRequest req = new HttpRequest(); 
                            HttpResponse res = new HttpResponse(); 
                            
                            req.setMethod('POST'); 
                            req.setEndPoint('http://192.XXX.XX.XX/eautomotive_enu/start.swe?'); 
                            req.setHeader('Content-type','text/xml'); 
                            req.setHeader('Content-Length',ContentLength.format()); 
                            req.setHeader('SoapAction','http://192.XXX.XX.XX/eautomotive_enu/start.swe?'); 
                            req.setBody(SoapXML); 
                            
                            System.Debug('@@@ req.getHeader'+req.getHeader('req.getHeader; '+'Content-Length')); 
                            System.Debug('@@@ req: '+req); 
                            System.Debug('@@@ req.getBody'+req.getBody()); 
                            
                            res = h.send(req);                             
                            System.Debug('@@@ res: === '+res);                             
                            String auth = res.getBody();                             
                            System.Debug('@@@ Debug(auth:'+auth);
        
        }      

}


DEBUG LOG : for the response. 

</head><body id=ERR_ACCESS_DENIED>
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr>

<div id="content">
<p>The following error was encountered while trying to retrieve the URL: <a href="http://192.XXX.XX.XX/eautomotive_enu/start.swe?">http://192.XXX.XX.XX/eautomotive_enu/start.swe?</a></p>

<blockquote id="error">
<p><b>Access Denied.</b></p>
</blockquote>

<p>Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.</p>

<p>Your cache administrator is <a href="mailto:support@salesforce.com?subject=CacheErrorInfo%20-%20ERR_ACCESS_DENIED&amp;body=CacheHost%3A%20proxy-was.net.salesforce.com%0D%0AErrPage%3A%20ERR_ACCESS_DENIED%0D%0AErr%3A%20%5Bnone%5D%0D%0ATimeStamp%3A%20Wed,%2017%20Feb%202016%2022%3A47%3A34%20GMT%0D%0A%0D%0AClientIP%3A%2010.242.12.23%0D%0A%0D%0AHTTP%20Request%3A%0D%0APOST%20%2Feautomotive_enu%2Fstart.swe%3F%20HTTP%2F1.1%0AContent-Type%3A%20text%2Fxml%0D%0AUser-Agent%3A%20SFDC-Callout%2F36.0%0D%0ASFDC_STACK_DEPTH%3A%201%0D%0AContent-Length%3A%20937%0D%0ASoapAction%3A%20http%3A%2F%2F192.168.10.14%2Feautomotive_enu%2Fstart.swe%3F%0D%0ACache-Control%3A%20no-cache%0D%0APragma%3A%20no-cache%0D%0AHost%3A%20192.168.10.14%0D%0AAccept%3A%20text%2Fhtml,%20image%2Fgif,%20image%2Fjpeg,%20*%3B%20q%3D.2,%20*%2F*%3B%20q%3D.2%0D%0AProxy-Connection%3A%20keep-alive%0D%0AX-Forwarded-For%3A%2010.242.64.10%0D%0A%0D%0A%0D%0A">support@salesforce.com</a>.</p>
<br>
</div>

<hr>
<div id="footer">
<p>Generated Wed, 17 Feb 2016 22:47:34 GMT by proxy-was.net.salesforce.com (squid)</p>
<!-- ERR_ACCESS_DENIED -->
</div>
</body></html>
Best Answer chosen by CloudGeek
Daniel BallingerDaniel Ballinger
The URL you provided for the web service seems very odd. Typically any IP v4 address starting with 192.168 would be a private network that isn't publically available. E.g. Something that your home router would setup to connect all the computers in your house.

Asking for the 192.168.X.X address would be like asking for something within Salesforces network infrastructure.

You will need to get the public IP address (or better server name) that resolves to the web service.


 

All Answers

Daniel BallingerDaniel Ballinger
The URL you provided for the web service seems very odd. Typically any IP v4 address starting with 192.168 would be a private network that isn't publically available. E.g. Something that your home router would setup to connect all the computers in your house.

Asking for the 192.168.X.X address would be like asking for something within Salesforces network infrastructure.

You will need to get the public IP address (or better server name) that resolves to the web service.


 
This was selected as the best answer
Vishnu Prasad 18Vishnu Prasad 18
hi CloudGeek

Are you able to solve this issue? If yes, please let me know what was the issue? if you have any document of integration between SFDC and Siebel (both way), please do share to vishnu3p@gmail.com
Naren9Naren9
Are you able to solve the issue of sending Account information from Salesforce to Siebel?. If yes, please share the high level steps.
I am able to Integrate the Siebel to Salesforce through Webservices, now I am trying the Salesforce to Siebel.

Thanks,
Narendar