How to use Ideone API in WSDL Format - api

I want to set up my own online compiler. I want to use Ideone Api for this. But its api is available in WSDL format. I tried very hard but could find any tutorial on how to extract data from WSDL. Please tell some way to use Ideone api.

Maybe a late answer but still may be useful for others. Here a simple example in PHP with it's native SOAP libray: http://ideone.com/3JBbt
Regretfully my server doesn't support PHP's SOAP library so I have used NuSOAP in the demo, now you have two ways to work with IDE One API.
Here a simple demo: http://rendon.x10.mx/files/ide1example/
And here is the code: http://rendon.x10.mx/files/ide1example.tar.gz
NOTE: You need provide your own user and password in ideone.php.
$params = array(
'user' => $user, // your user
'pass' => $pass, // your pass
'sourceCode' => $code,
'language' => $lang,
'input' => $input,
'run' => $run,
'private' => $private
);
For more info about the functions consult the API document: http://ideone.com/files/ideone-api.pdf

WSDL as name says, it describes functionality or the methods for communicating a webservice ,
As you said you have WSDL, then i would suggest you to create a WebService Client and start using it in your program.
For creating a WebService client, i would suggest you to use some tools such as Ex: http://cxf.apache.org/, they give you nice tools to create WS Clients like WS2js, WS2Java etc., kinda
As u've mentioned Ideone specifically , i'm working on it too, i would suggest you to look at creating a WSclient from WSDL in Netbeans(for this you need to download a plugin JAX-RPC)
or refer to this project http://code.google.com/p/ideone-cli/ , they've a working implementation of ideone WS Client.

Related

Using Laravel's Mailgun driver, how do you (gracefully) send custom data and tags with your email?

So I'm using Laravel 5.1 and trying to integrate with Mailgun. Well, that's easy, but now I'm trying to send custom variables from my application along with my emails.
I'm actually switching our application over from Mandrill because of their "new direction" and such. With them, I could supply the variables and tags via the email headers, but with Mailgun, that only works when you send via SMTP. In Laravel, Mail::send() uses an API call, so in theory I'd add the metadata there with "v:my-custom-data" => "{"this_id": 123}", but I'd like to avoid altering core classes like that.
I also considered using Bogardo/Mailgun, but then I'd have to replace all the Mail::send()s with Mailgun::send(), and then I couldn't send emails locally (environment based email driver), and then the application would be "married" to Mailgun.
Anyone done this before? Please let me know if I'm not clear here.
I fixed my own problem. I was wrong, YOU CAN add custom variables via the SMTP method:
// Send email with custom variables and tags in Laravel
Mail::send('emails.blank',
['html' => 'This is a test of Mailgun. <strong>How did it work out?</strong>'],
function($message) {
$message->to('jack#mailinator.com');
$message->subject('Mailgun API Test');
$headers = $message->getHeaders();
$headers->addTextHeader('X-Mailgun-Variables', '{"msg_id": "666", "my_campaign_id": 1313}');
$headers->addTextHeader('X-Mailgun-Tag', 'test-tag');
});
My testing was just inadequate. Very good to know, however I think this is an undocumented feature, so I suggest using with caution.
Update for Laravel 5.4+
As you can read in the offical docs:
The withSwiftMessage method of the Mailable base class allows you to register a callback which will be invoked with the raw SwiftMailer message instance before sending the message. This gives you an opportunity to customize the message before it is delivered:
/**
* Build the message.
*
* #return $this
*/
public function build()
{
$this->view('emails.orders.shipped');
$this->withSwiftMessage(function ($message) {
$message->getHeaders()
->addTextHeader('Custom-Header', 'HeaderValue');
});
}
You can just do like this in Laravel 5 :
Mail::send(['text' => 'my_template'], $data, function ($message) {
..
$message->getSwiftMessage()->getHeaders()->addTextHeader('X-Mailgun-Tag', 'my-tag');
});
Laravel implementation of the Mailgun Driver doesn't support options/parameters.
Here's a Gist which adds support to the native driver : https://gist.github.com/j0um/27df29e165a1c1e0634a8dee2122db99

intern test not using configured registry requestProvider in dojo

I'm following this article to mock response in dojo.
My mocker is very similar to the one in the article except this:
registry.register(/\/testIntern/, function (url, options) {
return when({
value: "Hello World"
});
In my understanding, this should map to any request that contains "/testIntern" on the address.
My testcase is quite simple:
// similar to example
var testRest= new Rest("/testIntern", true);
testRest("").then(lang.hitch(this, function (data) {
assert.deepEqual("Hello World", data.value, "Expected 'Hello World', but got" + data.value);
}));
It really should be quite simple. But when I run this test, I got 404 Not Found. It looks like the REST call in the test doesn't try to use the mocking service. Why?
You are generally correct in your thought that registering a URL with dojo/request/registry should pass anything referencing that URL via dojo/request through your handler.
Unfortunately, dojo/store/JsonRest uses the dojo/_base/xhr module which uses dojo/request/xhr directly, not dojo/request. Any registrations created with dojo/request/registry (and any setting of defaultProvider) will unfortunately be lost on JsonRest.
You might want to have a look at dstore - its Rest store implements the same server requests as dojo/store/JsonRest but it uses dojo/request instead of being hard-coded to a specific provider. (dojo/request defaults to dojo/request/xhr in browsers anyway, but can be overridden via dojoConfig.requestProvider.) dstore contains adapters for translating between dstore's API and the dojo/store API, if you need to use it with widgets that operate with the latter.

Stub for google calendar API when using rspec in ROR3

The following is the method I am trying to use for getting the API to make the calls to Google calendar. I am not sure what the stub should return. Should I capture the normal response and use it as is or is there a reference with minimum set of parameters?
api = client.discovered_api('calendar', 'v3')
result = client.execute!(:api_method => api.calendar_list.list)
I can see that Omniauth provides it's own mock support and I can see that Google provides Python mock libraries, but I'm not aware of any direct Google support for mocking from Ruby.
That said, given your example, you would need test doubles for client and api. It's not clear where client is coming from, but assuming that's established as a double somehow, you'd have at a minimum:
api = double('api')
client.should_receive(:discovered_api).and_return(api)
api.stub_chain(:calendar_list, :list)
client.should_receive(:execute!).and_return(... whatever result you want ...)
If in addition you want to confirm that your code is passing the right parameters to the Google API, then you'd need to augment the above with message expectations and, in the case of the api stub_chain, a return value which would then have to feed into the message expectations for the execute! call.
I'm still not sure that answers your question, but if not, I'll look forward to reading any additional comments.

Interacting with a REST API from Clojure

What would be the suggested way to send and receive requests to an external REST API without having to run a web server? I can't seem to find anything about making requests and parsing the resulting JSON. The only thing I have found so far is just the json parsing stuff (using the Cheshire library).
Any help would be greatly appreciated!
A good library for interacting with an external REST API is clj-http, which uses Apache HTTPClient). For JSON, there are a few options: clojure.data.json (a core lib) and cheshire being some popular ones. The lib clj-http has cheshire as a dependency and has JSON support baked in. Cheshire makes use of Jackson.
For example, using clj-http:
(ns my.core
(:require [clj-http.client :as client]))
(client/put my-url
{:form-params body
:content-type :json
:oauth-token #token
:throw-exceptions false
:as :json})

Rest and ZF session management

I'm trying to create a web service which utilizes Zend framework. The API is REST based and uses Zend_Rest_Controller as base class. I wish to have user management and session, and for that I'm using the following code:
Login (POST)
// user id and password fetched first
$users = new Application_Model_DbTable_UserInfo();
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(),'users');
$authAdapter->setIdentityColumn('userid')
->setCredentialColumn('password');
$authAdapter->setIdentity($userid)
->setCredential($pwd);
$result = $auth->authenticate($authAdapter);
if($result->isValid()){
Zend_Session::rememberMe(604800);
$storage = new Zend_Auth_Storage_Session();
$usa = $authAdapter->getResultRowObject();
$auth->getStorage()->write($usa);
$authSession = new Zend_Session_Namespace('Zend_Auth');
$authSession->setExpirationSeconds(60*60);
}
and when accessing the service with e.g. some GET method I wish to check that there is a valid session with the following code:
$auth = Zend_Auth::getInstance();
if(!$auth->hasIdentity())
{
// error handling etc.
}
I never get an identity, hence the service doesn't work.
I have followed the guidance for ZF authentication quite strictly, but does the REST stuff need additional items to be taken into account?
I know I'm not answering your question, but if you are REALLY planning to implement a true REST interface (which implies it's going to enable you to scale well), you'd probably better forget about sessions and using Zend_Auth in the way you've depicted above.
Take a look here, where something about REST interfaces and authentication has been discussed already:
Can you help me understand this? "Common REST Mistakes: Sessions are irrelevant"
In short, quoting from the Q/A thread above, "To be RESTful, each HTTP request should carry enough information by itself for its recipient to process it to be in complete harmony with the stateless nature of HTTP". I really feel like seconding that.