+ Start a Discussion
Integrator9Integrator9 

GET response on Submitting HTML Form from Visualforce

Hi,

 

I am Using a Visualforce Page with HTML Form which POST s Data to a URL.

 

When i Click Submit (HTML) Button the form action is calling a External URL(which i am sending Data) , and on that Page some response is Displayed.

 

Can we get that response back to Visualforce or Pass to Controller so that I can save that back in Salesforce.

 

Please suggest any solution.

 

Thanks in advance.

 

My Form Code:

<apex:page>

<form name="form1" method="post" action= "https://www1.abc.com/partners/abcd/" target="blank">
<input type="submit" name="Submit" value="Initiate"/>
<input type="hidden" name="ExpressXML" value="{!XML}"/>

</form>

</apex:page>

 

 

Mohith Kumar ShrivastavaMohith Kumar Shrivastava

Why dont you prefer using HTTP Request methods on button click instead of using html?

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm

public class AuthCallout {
 
   public void basicAuthCallout(){
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://www.yahoo.com');
     req.setMethod('GET');
     
     // Specify the required user name and password to access the endpoint 
    
     // As well as the header and header information 
    
 
     String username = 'myname';
     String password = 'mypwd';
  
     Blob headerValue = Blob.valueOf(username + ':' + password);
     String authorizationHeader = 'BASIC ' +
     EncodingUtil.base64Encode(headerValue);
     req.setHeader('Authorization', authorizationHeader);
   
     // Create a new http object to send the request object 
    
     // A response object is generated as a result of the request   
    
  
     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getBody());
   }
}

 

Integrator9Integrator9

Hi,

 

Thanks for the Reply,

 

This Approach i used but in this approach i am un able to pass XML to the SERVER, its giving response as XML content Missing.

I tried different ways like sending XML as Setbody, setbodydocument , even set header etc.. but i am un able to send the XML to their server.

 

so i am trying if i can read the response using the HTML form.

 

Thanks