How to call a method in WSDL from Salesforce callout - salesforce

I m a new bie to the salesforce, and I m trying to get the response by calling a wsdl file from the salesforce.
I dont know how to call a method of the WSDL from HTTP callouts
The code is something Like this :-
//HTTP request
HttpRequest req = new HttpRequest();
req.setEndpoint('domain.com/webservices/wwservice.php?wsdl');
req.setMethod('GET');
ANd I m calling the HTTP request and response from the TestMethod.
The result I m getting is System.HttpResponse[Status=null, StatusCode=0] .
Please help me out in this.

First you need to download the WSDL to your local machine, then upload the WSDL to Salesforce.com (Apex-->Generate from WSDL). This will generate the Apex classes needed to actually call web services described in the WSDL.
Anyway, it's all described here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex.htm

Related

Https url data download issue with apache camel

I am facing a unique problem with apache camel https4 call. My case is something like below:
I have to make a post https request to a third party with authentication credentials(request identifiers) in body of request. - This works fine
Example url : https4://< requesturl >?httpClientConfigurer=proxyClientConfigurer
The successful response will give me a download url to request for files download. This url is returned in the format https://< requesturl >?args=< file identifier > which if i invoke through a browser, downloads all the files instantly.
However for invoking it through apache camel i have to use https4 and need to append httpClientConfigurer=proxyClientConfigurer to download request url. So the final url is something like https4://< requesturl >?args=< file identifier>&httpClientConfigurer=proxyClientConfigurer and this is the part its failing.
the server treat it as a new request and looks for the authentication/information which is not present and hence the call fails.
I don't know what i am doing wrong here?
Well i didn't find a solution for this through Camel but i went ahead and used the normal Http Get with the download url.

Unable to get the xml response from zillow api webservice which is called from angularjs

I'm trying to call the zillow api webservice url from angular js.
The following is my source code :
$http.get('http://www.zillow.com/webservice/GetZestimate.htm?zws-id=<ZWSID>&zpid=48749425').success(function(response) {
alert(response) ;
console.log(response);
});
It is giving the following error :
XMLHttpRequest cannot load http://www.zillow.com/webservice/GetZestimate.htm?zws-id=<ZWSID>&zpid=48749425.No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8080' is therefore not allowed access
Please anyone help me.
Thanks in advance.!
From this Link :
Zillow API Error:"No 'Access-Control-Allow-Origin' header is present"
Zillow doesn't support a JavaScript API so we would need to create own server-side service that queries it (forwards the query) and sits on the same domain as our HTML page.
The following post gives the full code using java
How to send data to an API call and get it back, using zillow.com API

Http request and response lost after receiving Response from Web Service?

I have an Apache camel application which talks with a web service. This is purely a integration(mediation) application. We take REST request and transform it to a SOAP message (using VM templates) and call the web service. Receive response from web service, transform it to JSON and send back to our client.
REST ---->transform to SOAP req (Velocity template) ---->call WS ---->receive response---->transform into JSON---->return response to caller.
We are using servlet endpoint to receive request from our client. We can obtain HttpSession object from exchange before calling web service as follows :
HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
HttpSession session = req.getSession();
However, the problem is that I cannot obtain HTTPSession from exchange after receiving response from web service. If I check the Exchange object in debug mode, the Exchange.getIn() is of type DefaultMessage rather than HttpMessage. That is the reason I think I loose Request and response objects.
I tried setting the exchange pattern to InOut but that doesn’t help.
The only solution I could find is to store the original body of the in message in a header or a property and retrieve it at the end. But I think there must be a better solution that this.
Could anybody help please?
Note: We need HttpSession so that we can store corresponding session information like session id created on WS for the session created by our request. We cannot pass session information created on WS to our callers, and need a place on our application to hold this mapping info. HttpSession serves this requirement. Is there any better way?
You can store the http session as an exchange property, camel copy these properties across the exchanges, so you can access it in the route when you need.

Is apache commons like HttpClient library equivalent supported in Apex Code on Salesforce's Force.com Platform?

I am trying to perform an external Http REST API callout using Apex Class from within my Salesforce Development Organization.
I was wondering if there is support for an equivalent HttpClient library like that of Apache Commons' HttpClient. Is there one?
From the documentation I realize that one way of doing it would be use the System.Http class to perform the request. Refer here for :Salesforce's System Classes and System.Http.
Example:
public class HttpCalloutSample {
// Pass in the endpoint to be used using the string url
public String getContent(String url) {
// Instantiate a new http object
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
// Send the request, and return a response
HttpResponse res = h.send(req);
return res.getBody();
}
}
The reason I am asking this question is because I remember running across a Apex Code Snippet from a tutorial that used such an API. I cant seem to find it now.
P.S: I understand the the Apex Code is a different language and Java libraries like the HttpClient do not run on the Salesforce platform. And there may not be direct language level way to integrate them both, unless there is a Apex Code binding to the library.
The System.HTTP class and friends is the only way to make HTTP requests from ApexCode. As you say apex is not java and you can't run random java libraries in apex.

how to build a SOAP request in libcurl using C

i am new to libcurl and i want to create a SOAP request and send to web service. Can anyone send me some example or tutorial to read.
thanks in advance
See here, scroll down to the SOAP example by vivtek.

Resources