Hi Paul,

I have both scope attribute in services.xml
and the setManageSession(true) call in the client,
but it still does not work.
I attached my service.xml file and my client code.

And here is the response that i get frm the server:


3f2

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:wsa="
http://www.w3.org/2005/08/addressing"; xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Header>

<wsse:Security xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
" soapenv:mustUnderstand="1"><wsu:Timestamp xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
" wsu:Id="Timestamp-23612966"><wsu:Created>2007-04-25T14:52:11.265Z</
wsu:Created><wsu:Expires>2007-04-25T14:57:11.265Z</wsu:Expires></
wsu:Timestamp></wsse:Security><wsa:Action>urn:echo</wsa:Action><
wsa:RelatesTo>urn:uuid:D6F41230DE1EAB89901177512730877</wsa:RelatesTo></
soapenv:Header><soapenv:Body><soapenv:Envelope xmlns:tns="
http://sample01.policy.samples.rampart.apache.org";><soapenv:Header /><
soapenv:Body><ns:sayHelloResponse xmlns:ns="http://sample/xsd";><ns:return>Hello
World</ns:return></ns:sayHelloResponse></soapenv:Body></soapenv:Envelope></
soapenv:Body></soapenv:Envelope>

0
Thanks,
Nencho


2007/4/25, Paul Fremantle <[EMAIL PROTECTED]>:

Nencho

Think of this as a cookie. The client has to be enabled to respond
with cookies, but that doesn't create the cookie in the first place.
To make this work you need to set

<service scope="soapsession">

in services.xml

Now the server will set the ref params in the reply-to header. If you
have setManageSession(true) now the client will send them back.

Paul

On 4/25/07, Nencho Lupanov <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I read this axis2 session management article:
> http://www.developer.com/java/web/article.php/3620661
>
> Basically, it says that i can define my services being of a soap session
> scope,
> then i have to put this option on my client:
> options.setManageSession(true);
>
> Therefore it is expected for the service to include
> <wsa:ReferenceParameters>
> element as an session identifier in the soap envelope.
>
> I tested this and it does not work - axis2 does not put that element, in
> order
> to be used as session identifier.Am i missing something or this is a
bug?
>
> Thanks,
> Nencho
>
>


--
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair

http://bloglines.com/blog/paulfremantle
[EMAIL PROTECTED]

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


<?xml version="1.0" encoding="UTF-8"?>
<!--
 !
 ! Copyright 2006 The Apache Software Foundation.
 !
 ! Licensed under the Apache License, Version 2.0 (the "License");
 ! you may not use this file except in compliance with the License.
 ! You may obtain a copy of the License at
 !
 !      http://www.apache.org/licenses/LICENSE-2.0
 !
 ! Unless required by applicable law or agreed to in writing, software
 ! distributed under the License is distributed on an "AS IS" BASIS,
 ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ! See the License for the specific language governing permissions and
 ! limitations under the License.
 !-->
<!-- services.xml of sample-1 : UsernameToken-->
<serviceGroup>
<service name="sample01" scope="soapsession">
	<operation name="echo">
		<messageReceiver class="com.softwareag.wsstack.messagereceivers.SampleMessageReceiver"/>
	</operation>    
	<parameter name="ServiceClass" locked="false">org.apache.rampart.samples.policy.sample01.SimpleService</parameter>
	
	<module ref="rampart" />
	<module ref="addressing" />

	<wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy";>
		<wsp:ExactlyOne>
		  <wsp:All>
			<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
			  <wsp:Policy>
				<sp:TransportToken>
				  <wsp:Policy>
					<sp:HttpsToken RequireClientCertificate="false"/>
				  </wsp:Policy>
				</sp:TransportToken>
				<sp:AlgorithmSuite>
				  <wsp:Policy>
					<sp:Basic256/>
				  </wsp:Policy>
				</sp:AlgorithmSuite>
				<sp:Layout>
				  <wsp:Policy>
					<sp:Lax/>
				  </wsp:Policy>
				</sp:Layout>
				<sp:IncludeTimestamp/>
			  </wsp:Policy>
			</sp:TransportBinding>
			<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
				<wsp:Policy>
					<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"; />
			  </wsp:Policy>
			</sp:SignedSupportingTokens>
			
			<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy";> 
				<ramp:passwordCallbackClass>org.apache.rampart.samples.policy.sample01.PWCBHandler</ramp:passwordCallbackClass>
			</ramp:RampartConfig>
			
		  </wsp:All>
		</wsp:ExactlyOne>
	</wsp:Policy>

</service>
</serviceGroup>

/*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.rampart.samples.policy.sample01;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;

import javax.xml.namespace.QName;

public class Client {

    public static void main(String[] args) throws Exception {
        
        if(args.length != 3) {
            System.out.println("Usage: $java Client endpoint_address 
client_repo_path policy_xml_path");
        }
        
        ConfigurationContext ctx = 
ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], 
null);
        
        ServiceClient client = new ServiceClient(ctx, null);
        Options options = new Options();
        options.setAction("urn:echo");
        options.setTo(new EndpointReference(args[0]));
        options.setManageSession(true);
        options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,  
loadPolicy(args[2]));
        client.setOptions(options);
        
        client.engageModule(new QName("addressing"));
        client.engageModule(new QName("rampart"));
        
        OMElement response = client.sendReceive(getPayload("Hello world"));
        
        System.out.println(response);

        System.out.println("!!!!!!!!!!!!!!   request again   !!!!!!!!!!!!");

        response = client.sendReceive(getPayload("Hello world"));
        
        System.out.println(response);


        
    }
    
    private static Policy loadPolicy(String xmlPath) throws Exception {
        StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
        return PolicyEngine.getPolicy(builder.getDocumentElement());
    }
    
    private static OMElement getPayload(String value) {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns = 
factory.createOMNamespace("http://sample01.policy.samples.rampart.apache.org/xsd","ns1";);
        OMElement elem = factory.createOMElement("echo", ns);
        OMElement childElem = factory.createOMElement("param0", null);
        childElem.setText(value);
        elem.addChild(childElem);
        
        return elem;
    }
    
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to