orbitz avatar orbitz committed 6c01373

Working fake SOAP calls

Comments (0)

Files changed (4)

Binary file added.

+{lib_dirs, ["deps"]}.
+
+{deps, [{ibrowse, "2.2.0", {git, "https://github.com/cmullaparthi/ibrowse.git", {branch, "master"}}}]}.
+

src/ide1_dirt.erl

+%%%-------------------------------------------------------------------
+%%% @author orbitz <orbitz@osx.local>
+%%% @copyright (C) 2011, orbitz
+%%% @doc
+%%% This implements the ideone SOAP calls, but not using SOAP.  I could
+%%% not get detergent to work.
+%%% @end
+%%% Created : 18 Oct 2011 by orbitz <orbitz@osx.local>
+%%%-------------------------------------------------------------------
+-module(ide1_dirt).
+
+-define(WSDL_URL, "http://ideone.com/api/1/service.wsdl").
+-define(SERVICES_URL, "http://ideone.com/api/1/service").
+
+%% API
+-export([call/2]).
+
+%%%===================================================================
+%%% API
+%%%===================================================================
+
+%%--------------------------------------------------------------------
+%% @doc
+%% @spec
+%% @end
+%%--------------------------------------------------------------------
+call(Operation, Args) ->
+    Request = envelope(body(operation(Operation, Args))),
+    Url = ?SERVICES_URL ++ "#" ++ Operation,
+    {ok, "200", _Headers, Body} = ibrowse:send_req(?SERVICES_URL,
+                                                   [{"SOAPAction", Url}],
+                                                   post,
+                                                   Request),
+    {ok, Body}.
+    
+
+%%%===================================================================
+%%% Internal functions
+%%%===================================================================
+envelope(Str) ->
+    "<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" " ++
+        "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" " ++
+        "xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" " ++
+        "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" " ++
+        "xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">" ++
+        Str ++
+        "</SOAP-ENV:Envelope>".
+
+body(Str) ->
+    "<SOAP-ENV:Body>" ++
+        Str ++
+        "</SOAP-ENV:Body>".
+
+
+operation(Operation, Args) ->
+    "<ns1:" ++ Operation ++
+        " xmlns:ns1=\"http://ideone.com/api/1/service\" SOAP-ENC:root=\"1\">" ++
+        arguments(Args) ++
+        "</ns1:" ++ Operation ++ ">".
+
+arguments(Args) ->
+    arguments(1, Args).
+
+arguments(_Index, []) ->
+    "";
+arguments(Index, [{Type, Value} | Rest]) ->
+    Index_str = integer_to_list(Index),
+    "<v" ++ Index_str ++
+        " xsi:type=\"" ++ Type ++ "\">" ++
+        Value ++
+        "</v" ++ Index_str ++ ">" ++
+        arguments(Index + 1, Rest).
+
+                        

src/iderlone.app.src

+{application, iderlone,
+ [
+  {description, ""},
+  {vsn, "1"},
+  {registered, []},
+  {applications, [
+                  kernel,
+                  stdlib
+                 ]},
+  {mod, { iderlone_app, []}},
+  {env, []}
+ ]}.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.