Forum Discussion
Hi qinglau,
Just to clarify, are you wanting to query Lithium via SOAP, or are you wanting to make an external SOAP request to some other service and pull the results into Lithium?
If the former, Lithium does not currently support API requests via SOAP.
If the latter, I'd suggest checking out the http.request context object:
It wasn't necessarily created with SOAP in mind, but if you can construct the necessary XML for your request, you might be able to get back the information you're looking for.
I hope this helps!
Hi Adam,
I would like to make a soap call to external server to grab information from another server. Thank you for your reply. I will try to do that by using http.client FreeMaker
Will keep you update how the development is going.
Cheers,
Qing
- qinglau12 years agoMentor
Hi Adam,
I try to use endpoints to make http.client request by following your recommendation KB:
The first thing i did , it is to add the allow domain setting in System. (Please see the attachment: http_client_setting) . I create a really simple http client request in my endpoints. The code are:<#assign response=http.client.request("http://tomtom-uk--tst.tomtom.com/cgi-bin/tomtom_uk.cfg/services/soap?wsdl").get().content /> <#if response.hasError> ${response.error.message} </#if> ${response}
The response either complian java.lang.exception error message or empty; it depends on how I set the view content type. If I set the view content type to text/xml, i will get java.lang.exception error message.
error> Error on line 1, column 1 in demo_context_object.ftl http.client.request("http://tomtom-uk--tst.tomtom.com/cgi-bin/tomtom_uk.cfg/services/soap?wsdl").get().content is undefined. It cannot be assigned to response The problematic instruction: ---------- ==> assignment: response=http.client.request("http://tomtom-uk--tst.tomtom.com/cgi-bin/tomtom_uk.cfg/services/soap?wsdl").get().content [on line 1, column 1 in demo_context_object.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Error on line 1, column 1 in demo_context_object.ftl http.client.request("http://tomtom-uk--tst.tomtom.com/cgi-bin/tomtom_uk.cfg/services/soap?wsdl").get().content is undefined. It cannot be assigned to response at freemarker.core.Assignment.accept(Assignment.java:111) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:237) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:366) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:283) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:233) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at lithium.servlet.spring.SpringControllerDispatcherServlet.service(SpringControllerDispatcherServlet.java:80) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at
If the view/content type is html, i will get empty return.
I am wondering it must be something I make it wrong, because I can get response if I paste the url (http://tomtom-uk--tst.tomtom.com/cgi-bin/tomtom_uk.cfg/services/soap?wsdl) in my browser.Can you please advices here? thank you
- AdamN12 years agoKhoros Oracle
Hi Qing,
One thing I noticed is that it appears you're trying to assign the response content to a variable before you're verified that the content exists. Perhaps try something like this instead and see if it gets you a bit further:
<#assign response=http.client.request("http://tomtom-uk--tst.tomtom.com/cgi-bin/tomtom_uk.cfg/services/soap?wsdl").get() /> <#if response.hasError> Error: ${response.error.message} <#else> ${response.content} </#if>
- ethienneroy8 years agoContributor
Is it still working in latest version?
I always get :
FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!)
An error has occurred when reading existing sub-variable "client"; see cause exception! The type of the containing value was: extended_hash+string (lithium.coreapi.webui.template.models.HttpTemplateModel wrapped into f.e.b.StringModel) ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign response = http.client.reques... [in template "preview" at line 36, column 1]
Related Content
- 7 years ago
- 6 months ago
- 10 years ago