What is the common way of accessing a web service and getting response JSON as Clojure maps ?
Do we have to use Java's java.net.URLConnection and Some JSON library like GSON ?
Is http-kit the most used library for this purpose, thats what I get via Google?
Take a look at clj-http. One of its dependencies is a JSON library called cheshire.
Here's an example of a basic GET request that parses the body as JSON.
(clj-http.client/get "http://example.com/foo.json" {:as :json})
For asynchronous HTTP you should look at http.async.client
Related
I have some external URL (restful api) to be integrated.
Those URL have different prefixed URL with different parameter at url, for example:
www.abc.com/books
www.abc.com/book/11
www.abc.com/book/11/authors
When get response from those invocation, esb needs to convert response from one json format to our standard json format.
I plan to use esb javascript mediator to perform convert operation, but I didn't find any way to attach url parameters.
Any one have any idea?
I have used mediator by java code to implement it, but it is too heavy.
I am also looking into connector for another option.
I have got a solution by use url template. By this solution, I can change url according to template defined.
With this solution, I didn't need to write mediator or connector.
First time using SOAP and wondering how can I make a simple SOAP request using django? I haven't yet tried setting up pysimplesoap, I first just want to make a connection to the webservice.
I have a string of the XML header and body
xml_header = ""
xml_body = ""
How can I send this request and wait for a response?
EDIT: I'm using Python 3.4 for SUDS is not an option
Another library worth checking out is Zeep.
Some of the more complex SOAP transactions are virtually impossible with SUDS, but are simple within ZEEP.
http://docs.python-zeep.org/en/master/
One way is to use the Suds library in your view: https://fedorahosted.org/suds/
Documentation: https://fedorahosted.org/suds/wiki/Documentation
I've been reading the edn spec and want to integrate it into my application. However, I don't know how to transfer edn requests between clojure and client. Do we put a content-type application/edn in the response header and just send the prn output string?
Although it has not yet been accepted by IANA (June 14, 2013), the correct content-type is application/edn. To provide a valid string output of your clojure object, use (pr-str obj). For a web service, the method of encoding and decoding depends on your web framework and your needs.
Pedestal supports parsing of edn into an :edn-params key on its request map through the use of its body-params interceptor. Sending clojure objects as edn is handled automatically if your response bodies are not strings. For content-negotiation, see pedestal-content-negotiation.
For ring middleware, ring-edn parses edn into an :edn-params key, but does not do any outbound modification. ring-middleware-format provides parsing of a handful of different formats into the :body-params key, and has a collection of middlewares that can be helpful for responses as well. There are a handful of other ring middleware projects like this out there.
I've created a ColdFusion Web Service, but it's returning WDDX instead of SOAP. How do I make it return SOAP instead of WDDX?
Have the <cffunction> return an XML object, and have the "returnformat" parameter be set to "plain".
<cffunction name="GetData" returntype="xml" returnformat="plain">
For complex objects, you need to setup the CFCs correctly. Read: Using ColdFusion components to define data types for web services
update: Or, you can create the XML representation of your object yourself with <cfxml>, then return the XML object with returnType="xml" in cffunction.
You may check out coldbox's XMLConverter Plugin as code sample for converting built-in CF complex types into XML.
A CFC method with access=remote ought to return soap, rather than WDDX. I'm sure I've used this functionality for years. What I'm suspecting may be happening is that the content-type is based on the request a client makes. I would download Soap-UI and test http://your.server/yourCFC.cfc?wsdl to see whether SOAP-UI gets WDDX thrown back at it. If is does, I'm at a bit of a loss, but do report it here anyway and I'll take a further look.
If Soap-UI sees a proper response, take a look at the headers it's sending and compare them to the request you're making (possibly through the browser?)
You can also use Fiddler to record soap-ui traffic and compare that against any other source of requests.
The http request thing above may be completely off, but it's relatively easy to check and I think it's ringing a bell.
You may also want to check the return type of the function you're writing. In order for CF to generate a good WSDL, it needs to be able to extract metadata from the CFC you're returning.
A bit late to the game but were you hitting it as a plain HTTP request and not as with a SOAP packet?
For example were you doing this:
http://api.example.com/something.cfc?method=test&arg1=val1
instead of an actual SOAP request with envelope, headers, body, etc?
The HTTP request returns WDDX by default or JSON by specifying the returnformat, while a SOAP request will return data in the format you are seeking.
How to make HTTP Json requests in C++? Any library? Under "HTTP Json request" I mean make POST with Json object as data and receive result as Json.
Use libCURL to get the actual JSON data. Then parse it with some C++ library like jsoncpp.