Daniel, I send you the wsdl. I write some code (from an example). I'm going
in the correct way?, I mean, now I have a "no certificate for user ..." and
it's obviusly that is the keystore, but.. my code is correct?.

Thanks!!


            SpringBusFactory bf = new SpringBusFactory();
            URL busFile = Client.class.getResource("wssec.xml");
            Bus bus = bf.createBus(busFile.toString());
            SpringBusFactory.setDefaultBus(bus);

            Map<String, Object> outProps = new HashMap<String, Object>();
            outProps.put("action", "Timestamp Signature Encrypt");
            outProps.put("passwordType", "PasswordDigest");
            outProps.put("user", "XXX");
            outProps.put("passwordCallbackClass",
com.casa.wss.demo.UTPasswordCallback.class.getName());
            outProps.put("encryptionUser", "YYY");
            outProps.put("encryptionPropFile", "Client_Encrypt.properties");
            outProps.put("encryptionKeyIdentifier", "SKIKeyIdentifier");
            outProps.put("signaturePropFile", "Client_Sign.properties");
            outProps.put("signatureKeyIdentifier", "DirectReference");

            String encryptionParts = "{Element}{
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp
;"
                + "{Element}{http://www.w3.org/2005/08/addressing}Action;";
                + "{Element}{http://www.w3.org/2005/08/addressing}ReplyTo;";
                + "{Element}{http://www.w3.org/2005/08/addressing}MessageID
;"
                + "{Element}{http://www.w3.org/2005/08/addressing}To;";
                + "{Content}{http://www.w3.org/2003/05/soap-envelope}Body";;

            outProps.put("signatureParts", encryptionParts);
            outProps.put("encryptionParts", encryptionParts);

            bus.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));

            Map<String, Object> inProps = new HashMap<String, Object>();
            inProps.put("action", "Timestamp Signature Encrypt");
            inProps.put("passwordType", "PasswordText");
            inProps.put("passwordCallbackClass",
com.casa.wss.demo.UTPasswordCallback.class.getName());
            inProps.put("decryptionPropFile", "Client_Sign.properties");
            inProps.put("encryptionKeyIdentifier", "IssuerSerial");
            inProps.put("signaturePropFile", "Client_Encrypt.properties");
            inProps.put("signatureKeyIdentifier", "DirectReference");

            bus.getInInterceptors().add(new WSS4JInInterceptor(inProps));

            final QName SERVICE_NAME = new QName("http://tempuri.org/";,
"MenStock");
            MenStock ss = new MenStock(MenStock.WSDL_LOCATION,
SERVICE_NAME);
            IStock port = ss.getCustomBindingIStock();

            System.out.println("Invoking mensajeStock...");
            org.datacontract.schemas._2004._07.wcf_stock.Stock stock = new
org.datacontract.schemas._2004._07.wcf_stock.Stock();


javax.xml.bind.JAXBElement<org.datacontract.schemas._2004._07.wcf_stock.ArrayOfStockEntrada>
stockEntradas = null;
            stockEntradas = createArrayOfStockEntrada();
            stock.setEntradas(stockEntradas);
            Object response = port.mensajeStock(stock);
            System.out.println("response: " + response + "\n");

            // allow aynchronous resends to occur
            Thread.sleep(30 * 1000);

            bus.shutdown(true);







2010/12/1 Daniel Kulp <[email protected]>

> On Monday 29 November 2010 5:28:37 pm Juan Pablo Pizarro wrote:
> > Hello, I'm trying to call a web service that uses certificates (
> > http://wss.aduanas.gub.uy/LuciaWsSecurity/Sthe WSS4J*Interceptors
> directly as 
> beloock.svc?wsdl<http://wss.aduanas.gub.uy/LuciaWsSecurity/Stock.svc?wsdl>).
> Can you guys
> > send me a tutorial to do that?
>
> We don't have access to that WSDL.
>
>
> > In this project I can not use spring (I saw some tutorials using spring).
> > Exists a tutorial using only cxf to do that?
>
> It depends.   If the WSDL contains WS-SecurityPolicy assertions, the
> easiest
> thing to do is let the WS-SecurityPolicy runtime just handle everything.
> You'll just need to configure in the crypto stuff.   Some (very little)
> docs
> are at:
> http://cxf.apache.org/docs/ws-securitypolicy.html
>
> If it doesn't contain the SecPolicy things, then you would need to
> configure
> the WSS4J*Interceptors directly as below.
>
> Dan
>
>
>
> >
> >
> > From CXF site (http://cxf.apache.org/docs/ws-security.html), I saw that
> we
> > can put interceptors to do that:
> >
> > import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
> > import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
> > ...
> >
> > Map<String,Object> inProps= new HashMap<String,Object>();
> > ... // how to configure the properties is outlined below;
> >
> > WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
> > cxfEndpoint.getInInterceptors().add(wssIn);
> > cxfEndpoint.getInInterceptors().add(new SAAJInInterceptor()); // 2.0.x
> > only; not needed in 2.1+
> >
> > Map<String,Object> outProps = new HashMap<String,Object>();
> > ... // how to configure the properties is outlined below;
> >
> > WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
> > cxfEndpoint.getOutInterceptors().add(wssOut);
> > cxfEndpoint.getOutInterceptors().add(new SAAJOutInterceptor());
> >
> >
> > But I can not find the method to get the cxfEndpoint from my classes. I'm
> > using snapshot 2.4.
> >
> > Thanks!
>
> --
> Daniel Kulp
> [email protected]
> http://dankulp.com/blog
>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="MenStock" targetNamespace="http://tempuri.org/";
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
	xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata";
	xmlns:tns="http://tempuri.org/"; xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing";
	xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"; xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy";
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract";
	xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"; xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/";
	xmlns:wsa10="http://www.w3.org/2005/08/addressing"; xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex";>
	<wsp:Policy wsu:Id="CustomBinding_IStock_policy">
		<wsp:ExactlyOne>
			<wsp:All>
				<sp:AsymmetricBinding
					xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
					<wsp:Policy>
						<sp:InitiatorToken>
							<wsp:Policy>
								<sp:X509Token
									sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient";>
									<wsp:Policy>
										<sp:WssX509V3Token10 />
									</wsp:Policy>
								</sp:X509Token>
							</wsp:Policy>
						</sp:InitiatorToken>
						<sp:RecipientToken>
							<wsp:Policy>
								<sp:X509Token
									sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never";>
									<wsp:Policy>
										<sp:WssX509V3Token10 />
									</wsp:Policy>
								</sp:X509Token>
							</wsp:Policy>
						</sp:RecipientToken>
						<sp:AlgorithmSuite>
							<wsp:Policy>
								<sp:Basic256 />
							</wsp:Policy>
						</sp:AlgorithmSuite>
						<sp:Layout>
							<wsp:Policy>
								<sp:Lax />
							</wsp:Policy>
						</sp:Layout>
						<sp:IncludeTimestamp />
						<sp:OnlySignEntireHeadersAndBody />
					</wsp:Policy>
				</sp:AsymmetricBinding>
				<sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
					<wsp:Policy>
						<sp:MustSupportRefKeyIdentifier />
						<sp:MustSupportRefIssuerSerial />
					</wsp:Policy>
				</sp:Wss10>
				<sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
					<wsp:Policy>
						<sp:MustSupportIssuedTokens />
						<sp:RequireClientEntropy />
						<sp:RequireServerEntropy />
					</wsp:Policy>
				</sp:Trust10>
				<wsaw:UsingAddressing />
			</wsp:All>
		</wsp:ExactlyOne>
	</wsp:Policy>
	<wsp:Policy wsu:Id="CustomBinding_IStock_MensajeStock_Input_policy">
		<wsp:ExactlyOne>
			<wsp:All>
				<sp:SignedParts
					xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
					<sp:Body />
					<sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"; />
				</sp:SignedParts>
			</wsp:All>
		</wsp:ExactlyOne>
	</wsp:Policy>
	<wsp:Policy wsu:Id="CustomBinding_IStock_MensajeStock_output_policy">
		<wsp:ExactlyOne>
			<wsp:All>
				<sp:SignedParts
					xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
					<sp:Body />
					<sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"; />
					<sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"; />
				</sp:SignedParts>
			</wsp:All>
		</wsp:ExactlyOne>
	</wsp:Policy>
	<wsdl:types>
		<xsd:schema targetNamespace="http://tempuri.org/Imports";>
			<xsd:import
				schemaLocation="http://wss.aduanas.gub.uy/LuciaWsSecurity/Stock.svc?xsd=xsd0";
				namespace="http://tempuri.org/"; />
			<xsd:import
				schemaLocation="http://wss.aduanas.gub.uy/LuciaWsSecurity/Stock.svc?xsd=xsd1";
				namespace="http://schemas.microsoft.com/2003/10/Serialization/"; />
			<xsd:import
				schemaLocation="http://wss.aduanas.gub.uy/LuciaWsSecurity/Stock.svc?xsd=xsd2";
				namespace="http://schemas.datacontract.org/2004/07/WCF_Stock"; />
		</xsd:schema>
	</wsdl:types>
	<wsdl:message name="IStock_MensajeStock_InputMessage">
		<wsdl:part name="parameters" element="tns:MensajeStock" />
	</wsdl:message>
	<wsdl:message name="IStock_MensajeStock_OutputMessage">
		<wsdl:part name="parameters" element="tns:MensajeStockResponse" />
	</wsdl:message>
	<wsdl:portType name="IStock">
		<wsdl:operation name="MensajeStock">
			<wsdl:input wsaw:Action="http://tempuri.org/IStock/MensajeStock";
				message="tns:IStock_MensajeStock_InputMessage" />
			<wsdl:output wsaw:Action="http://tempuri.org/IStock/MensajeStockResponse";
				message="tns:IStock_MensajeStock_OutputMessage" />
		</wsdl:operation>
	</wsdl:portType>
	<wsdl:binding name="CustomBinding_IStock" type="tns:IStock">
		<wsp:PolicyReference URI="#CustomBinding_IStock_policy" />
		<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"; />
		<wsdl:operation name="MensajeStock">
			<soap12:operation soapAction="http://tempuri.org/IStock/MensajeStock";
				style="document" />
			<wsdl:input>
				<wsp:PolicyReference
					URI="#CustomBinding_IStock_MensajeStock_Input_policy" />
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<wsp:PolicyReference
					URI="#CustomBinding_IStock_MensajeStock_output_policy" />
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:service name="MenStock">
		<wsdl:port name="CustomBinding_IStock" binding="tns:CustomBinding_IStock">
			<soap12:address location="http://wss.aduanas.gub.uy/LuciaWsSecurity/Stock.svc"; />
			<wsa10:EndpointReference>
				<wsa10:Address>http://wss.aduanas.gub.uy/LuciaWsSecurity/Stock.svc
				</wsa10:Address>
				<Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity";>
					<Dns>wss.aduanas.gub.uy</Dns>
				</Identity>
			</wsa10:EndpointReference>
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

Reply via email to