Results 1 to 2 of 2

Thread: Webservice easy with Spring WS?

Hybrid View

  1. #1

    Default Webservice easy with Spring WS?

    I am connecting to a secured webservice using Spring ws. I have a security policy as below

    Security.xml

    <xwss:SecurityConfiguration xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
    <xwss:Sign includeTimestamp="true" />
    </xwss:SecurityConfiguration>

    and a bean config file as below

    webservice.xml

    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServi ceTemplate">
    <property name="interceptors">
    <list>
    <ref bean="wsSecurityInterceptor" />
    </list>
    </property>
    </bean>

    <bean id="wsSecurityInterceptor"
    class="org.springframework.ws.soap.security.xwss.X wsSecurityInterceptor">
    <property name="policyConfiguration" value="securityPolicy.xml" />
    <property name="callbackHandlers">
    <list>
    <ref bean="keyStoreHandler" />
    </list>
    </property>
    </bean>

    <bean id="keyStoreHandler"
    class="org.springframework.ws.soap.security.xwss.c allback.KeyStoreCallbackHandler">
    <property name="keyStore" ref="trustStore" />
    <property name="trustStore" ref="trustStore" />
    <property name="privateKeyPassword" value="changeit" />
    <property name="defaultAlias" value="testweb-1" />
    </bean>

    Client Code

    ApplicationContext context = new ClassPathXmlApplicationContext(
    "webservice.xml");

    WebServiceTemplate webServiceTemplate = (WebServiceTemplate) context
    .getBean("webServiceTemplate");

    System.out.println(createCustomerAuthenticationMes sage().getXML());
    StreamSource source = new StreamSource(new StringReader(
    createCustomerAuthenticationMessage().getXML()));
    StreamResult result = new StreamResult(System.out);


    webServiceTemplate
    .sendSourceAndReceiveToResult(
    "https://testweb.com/testservice.asmx",
    source, result);

    System.out.println("Test" + result);

    When I try to run the client the application throws the following exception

    Caused by: java.lang.NullPointerException: signingKey cannot be null

    I have imported the secured certificate in my truststore. A SOAP client written in pure java seems to work. The issue seems to be with the spring client only

  2. #2
    Join Date
    Dec 2007
    Location
    Zaragoza, Spain
    Posts
    17

    Default

    You need to specify signature to XWSS.

    Maybe this could help http://gleichmann.wordpress.com/2009...igning-client/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •