Return to Jive Software

Skip navigation

This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
1,447 Views 10 Replies Last post: Oct 15, 2009 8:37 PM by skeener RSS
skeener Novice 56 posts since
Sep 3, 2009
Currently Being Moderated

Oct 13, 2009 8:49 PM

Web Service question....

So I have been developing a simple web service based on suggestions from this forum.

 

I want to return pre-generated XML as a string.  I do not want any other xml wrapping around it.  (It's already pre-generated by a seperate module)

 

Suggestions on how to accomplish this?  I've got data being returned, but it's wrapped in outgoing XML similar to what's below around a dummy string:

 

<ns1:getKmlResponse xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
     <return><field1><value1></value1></field1></return>
</ns1:getKmlResponse>

 

The string response that I want corresponds to:

 

<field1><value1></value1></field1>

 

I'm trying to get rid of the rest of the wrappings.

 

Thanks!!!

gweinger Jive Employee 700 posts since
Jan 3, 2007
Currently Being Moderated
Oct 14, 2009 1:57 PM in response to: skeener
Re: Web Service question....

Hi Steve,

 

That markup is built into our REST framework; you're not going to get around it.

 

You could define an action that wraps the web service (or invokes the same APIs) and gives you the output you want.  You can avoid the sitemesh decoration by adding the following annotation to your class:

 

@Decorate(false)

 

See this for more info on that:  Struts: Frequently Asked Questions

 

What's your use case (just curious)?  Normally I'd clean up on the client end with a SAX parse or string manipulation.

gweinger Jive Employee 700 posts since
Jan 3, 2007
Currently Being Moderated
Oct 14, 2009 2:53 PM in response to: skeener
Re: Web Service question....

Gotcha.  Like a servlet filter that strips it?   Sounds nasty, sorry about that.  Good luck!

gweinger Jive Employee 700 posts since
Jan 3, 2007
Currently Being Moderated
Oct 15, 2009 11:23 AM in response to: skeener
Re: Web Service question....

How would you authenticate then, using Basic Auth like Web Services?

 

At that point you want to modify the Spring security filter chain to use a different authentication mechanism for that URL.    Let me know if you need more detail.

gweinger Jive Employee 700 posts since
Jan 3, 2007
Currently Being Moderated
Oct 15, 2009 11:34 AM in response to: skeener
Re: Web Service question....

You're basically creating a file in jiveHome/etc  that overrides some spring configs:

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"
       default-autowire="no" default-init-method="init" default-destroy-method="destroy">



    <!-- This bean is the main entry point of the Acegi Filter and a critical configuration point.
            Filters referenced here are defined below. -->
    <bean id="filterChainProxy">
        <property name="filterInvocationDefinitionSource">
            <value>
                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                PATTERN_TYPE_APACHE_ANT
                /upgrade/**=httpSessionContextIntegrationFilter, upgradeAuthenticationFilter, upgradeExceptionTranslationFilter,jiveAuthenticationTranslationFilter
                /post-upgrade/**=httpSessionContextIntegrationFilter, postUpgradeAuthenticationFilter, postUpgradeExceptionTranslationFilter,jiveAuthenticationTranslationFilter
                /admin/**=httpSessionContextIntegrationFilter, sessionTrackingFilter, adminAuthenticationFilter, openfireAuthenticationFilter, adminExceptionTranslationFilter,jiveAuthenticationTranslationFilter
                /rpc/xmlrpc=wsRequireSSLFilter, httpSessionContextIntegrationFilter, basicAuthenticationFilter, wsExceptionTranslator, jiveAuthenticationTranslationFilter, wsAccessTypeCheckFilter
                /rpc/rest/**=wsRequireSSLFilter, httpSessionContextIntegrationFilter, basicAuthenticationFilter, wsExceptionTranslator, jiveAuthenticationTranslationFilter, wsAccessTypeCheckFilter
                /rpc/soap/**=wsRequireSSLFilter, httpSessionContextIntegrationFilter, jiveAuthenticationTranslationFilter
                /**=httpSessionContextIntegrationFilter, sessionTrackingFilter, formAuthenticationFilter,  feedBasicAuthenticationFilter,exceptionTranslationFilter,jiveAuthenticationTranslationFilter
            </value>
        </property>
    </bean>

 

</beans>

Then you add in a new matcher that copies one of rpc matchers above but matches on your new Action's URL.


I talked to Len, we  can discuss this further at 4pm Eastern.

gweinger Jive Employee 700 posts since
Jan 3, 2007
Currently Being Moderated
Oct 15, 2009 12:55 PM in response to: skeener
Re: Web Service question....

No, you're right you can put it in the spring.xml in your plugin.


You don't have to impelement a new filter.   What I'm talking about is just adding a new line that uses just the filters you want, which I assume uses basic auth, e.g.:

 

<!-- This bean is the main entry point of the Acegi Filter and a critical configuration point.

            Filters referenced here are defined below. -->

    <bean id="filterChainProxy">

        <property name="filterInvocationDefinitionSource">

            <value>

                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON

                PATTERN_TYPE_APACHE_ANT

                /upgrade/**=httpSessionContextIntegrationFilter, upgradeAuthenticationFilter, upgradeExceptionTranslationFilter,jiveAuthenticationTranslationFilter

                /post-upgrade/**=httpSessionContextIntegrationFilter, postUpgradeAuthenticationFilter, postUpgradeExceptionTranslationFilter,jiveAuthenticationTranslationFilter

                /admin/**=httpSessionContextIntegrationFilter, sessionTrackingFilter, adminAuthenticationFilter, openfireAuthenticationFilter, adminExceptionTranslationFilter,jiveAuthenticationTranslationFilter

                /rpc/xmlrpc=wsRequireSSLFilter, httpSessionContextIntegrationFilter, basicAuthenticationFilter, wsExceptionTranslator, jiveAuthenticationTranslationFilter, wsAccessTypeCheckFilter

                /rpc/rest/**=wsRequireSSLFilter, httpSessionContextIntegrationFilter, basicAuthenticationFilter, wsExceptionTranslator, jiveAuthenticationTranslationFilter, wsAccessTypeCheckFilter

                /rpc/soap/**=wsRequireSSLFilter, httpSessionContextIntegrationFilter, jiveAuthenticationTranslationFilter

                /steveAction*=wsRequireSSLFilter,feedBasicAuthenticationFilter

               /**=httpSessionContextIntegrationFilter, sessionTrackingFilter, formAuthenticationFilter,  feedBasicAuthenticationFilter,exceptionTranslationFilter,jiveAuthenticationTranslationFilter

            </value>

        </property>

    </bean>

 

</beans>

gweinger Jive Employee 700 posts since
Jan 3, 2007
Currently Being Moderated
Oct 15, 2009 1:13 PM in response to: Gregory Weinger
Re: Web Service question....

So basically all you need is a filter you can plugin to the chain:

public class StevesProcessingFilter implements Filter, InitializingBean {

 

. . . .

 

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {

 

     SecurityContextHolder.getContext().setAuthentication(new AnonymousAuthentication());

    chain.doFilter(request, response);

}

 

. . .

}

More Like This

  • Retrieving data ...

Bookmarked By (0)