Forum Discussion

qinglau's avatar
qinglau
Mentor
12 years ago

Make a soap request in Lithium

Hi All, 

 

i am wondering whether there is someone has tried to make a soap request in Lithium platform. 

 

Can I use rest http call to do that? 

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

    <soapenv:Header>

        <ns7:ClientInfoHeader soapenv:mustUnderstand="0" xmlns:ns7="urn:messages.ws.rightnow.com/v1.1">

            <ns7:AppID>Run report sample</ns7:AppID>

        </ns7:ClientInfoHeader>

            <wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

                <wsse:UsernameToken><wsse:Username>bur</wsse:Username>

                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">********</wsse:Password>

                </wsse:UsernameToken>

            </wsse:Security>

    </soapenv:Header>

<soapenv:Body>

    <ns7:RunAnalyticsReport xmlns:ns7="urn:messages.ws.rightnow.com/v1.1">

        <ns7:AnalyticsReport xsi:type="ns4:AnalyticsReport" xmlns:ns4="urn:objects.ws.rightnow.com/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

            <ID id="146682" xmlns="urn:base.ws.rightnow.com/v1.1"/>

         </ns7:AnalyticsReport><ns7:Limit>1000</ns7:Limit><ns7:Start>0</ns7:Start>

    </ns7:RunAnalyticsReport>

</soapenv:Body>

</soapenv:Envelope>

 

Thank you 

  • AdamN's avatar
    AdamN
    Khoros Oracle

    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:

    http://lithosphere.lithium.com/t5/developers-knowledge-base/http-client-FreeMarker-Context-Object/ta-p/80614

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Using-the-http-client-Context-Object-to-Integrate-with-a-Third/ta-p/91640

    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!

    • qinglau's avatar
      qinglau
      Mentor

      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 

      • qinglau's avatar
        qinglau
        Mentor

        Hi Adam,

         

        I try to use endpoints to make http.client request by following your recommendation KB:

         

        1. https://lithosphere.lithium.com/t5/developers-knowledge-base/http-client-FreeMarker-Context-Object/ta-p/80614

        2. https://lithosphere.lithium.com/t5/developers-knowledge-base/http-client-response-FreeMarker-context-object/ta-p/80622


        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

         


        http_client_setting.pngendpoints.png