Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Spring and WSS4J Example

  1. #11
    Join Date
    Mar 2008
    Posts
    12

    Default

    Your SOAP request seems to have no security info, can I see your client configuration please.

  2. #12
    Join Date
    Mar 2008
    Posts
    23

    Default

    Quote Originally Posted by vijay.akula View Post
    Your SOAP request seems to have no security info, can I see your client configuration please.
    You're right; I'll take a look at my configuration and see if I can see why it is not picking that up. Here is my client config:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    	<bean id="wireFxServiceClient" parent="abstractClient"
    		class="com.pnc.wire.web.controller.WireFxServiceClient">
    		<property name="marshaller" ref="marshaller" />
    		<property name="unmarshaller" ref="marshaller" />
    	
    		<property name="interceptors">
    			<bean class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
    				<property name="securementActions" value="Signature"/>
    				<property name="securementUsername" value="wireUsr"/>
    				<property name="securementPassword" value="wirePass"/>
    				<property name="securementSignatureCrypto">
    					<bean class="org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean">
    						<property name="keyStorePassword" value="wirefx"/>
    						<property name="keyStoreLocation" value="classpath:/WEB-INF/wireFx.jks"/>
    					</bean>
    				</property>
    			</bean>
    		</property>
    	</bean>
    
    	<bean id="messageFactory"
    		class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
    
    	<bean id="abstractClient" abstract="true">
    		<constructor-arg ref="messageFactory" />
    		<property name="defaultUri"
    			value="http://localhost:9080/wire/services" />
    	</bean>
    
    	<bean id="marshaller"
    		class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="classesToBeBound">
    			<list>
    				<value>com.pnc.wire.fx.model.FxRateRequest</value>
    				<value>com.pnc.wire.fx.model.FxRateResponse</value>
    			</list>
    		</property>
    	</bean>
    </beans>

  3. #13

    Default

    vijay you little super star i have been looking for a step by step like this for a week now!

  4. #14

    Default Ok now with a marshaller

    ok i am trying this now with a jaxb marshalled message from the client.



    client applicationCtx.xml is

    Code:
           <bean id="client" class="Client">
           		<property name="marshaller" ref="marshaller"/>
           		<property name="unmarshaller" ref="marshaller"/>
           		<property name="defaultUri" value="http://localhost:8080/testWS/searchService"/>
           		<property name="interceptors">
           			<list>	
           				<ref local="wsInterceptor"/>
           			</list>
           		</property>
           </bean>
           
           <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
           		<property name="contextPath" value="uk.co.was.schema"/>
           </bean>
           
           <bean id="wsInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
           		<property name="securementActions" value="UsernameToken"/>
           		<property name="securementUsername" value="Ian"/>
           		<property name="securementPassword" value="password"/>
           </bean>
    the class looks like this

    Code:
    	public static void main(String[] args) {
    		ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml",Client.class);
    		Client client = (Client) ctx.getBean("client",Client.class);
    		client.getPolicies();
    	}
    	
    	public void getPolicies(){
    		PolicyHolderRequest req = jaxb.createPolicyHolderRequest();
    		req.setHolderName("param");
    		PolicyHolderResponse res = (PolicyHolderResponse) getWebServiceTemplate().marshalSendAndReceive(req);
    
    	}
    and the exception is as follows

    Code:
    Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: One or more mandatory SOAP header blocks not understood
    	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:37)
    	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:668)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:502)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:440)
    	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:289)
    	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:283)
    	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:275)
    	at Client.getPolicies(Client.java:31)
    	at Client.main(Client.java:22)
    clearly something going in the web service template, i looked in the api docs and there is a version of marshalSendReceive that takes the Object and a callbackHandler - however my understanding on the Wss4j interceptor was that it did it for you, any clues anyone?

  5. #15
    Join Date
    Jul 2010
    Posts
    5

    Default

    Hi, i have error during compilation :

    WSHandler: wrong part definition: {http://schema.mywebservice.com/xxx}a;

    and my code is:

    Code:
    <property name="securementEncryptionParts" value="{http://schema.mywebservice.com/xxx}a"/>
    What is the problem ?

    Thanks.

  6. #16

    Default

    Due to some insufficient data/credentials. The Security Header was not appended at the client side.
    Please verify the digital security generation at the client side !!!

    Note:
    Keystore & Certificate file are mandatory at client side.
    Keystore file is sufficient at server side.

    Example Command to generate Certificate File from Key store
    keytool -certreq -alias mydomain-keystore keystore.jks -file certi.csr

Posting Permissions

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