Tu ejemplos de código que trabajó en todas las configuracionesSabía que se estaba implementando eje correctamente
Felicidades Oscar ..tu duro trabajo.. ha trabajado correctamente
¡Saludos Amigo Mio!
Martín
______________________________________________
(contratista Banco Santander)
From: ***@hotmail.com
To: java-***@axis.apache.org
Subject: RE: Log xml request file
Date: Tue, 31 Mar 2015 12:04:59 +0200
Hi all,
I want to come back to you with very good news.
At the end, I found whatŽs the problem and the problem was the provider, I mean the company who is our provider.
Its Web Service was absolutely wrong, all your help applied to my code, even my first code works perfect.
After becoming very angry with the provider, and argued with him, I found that with the current Web Service provided by them was impossible to communicate.
I got angrier because I lost a lot of time on this and also I made some of you to lost time.
After fixing by provider the problem in its server, I succesfully communicate with the web Service just signing the request with the certificate (new certificate because the old one wasnŽt be valid by provider, incredible but it was truth) and log in perfect.
A want to say a very big thank you!!!!!!!!
Kind regards,
Oscar
From: ***@hotmail.com
To: java-***@axis.apache.org
Subject: RE: Log xml request file
Date: Wed, 11 Mar 2015 16:11:29 +0100
Hi all:
So sorry to come back with very bad news as I donŽt know how to go on. IŽm very new to rampart maybe itŽs that the problem.
Best way is to start from the top to the botton.
Top (literally how the provider has sent the info to me in English):
I have to call a Web Service with a request like this one:
<?xml version="1.0" encodin g="UTF-8"?>
<soapenv:Envelope xml ns: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" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" ValueType="ExperianWASP" EncodingType="wsse:Base64Binary" wsu:Id="SecurityToken">
RXJyb3IgaXNzRqluZyBhdXRoAz50aWNhdG4vbi20b2tlbg==
</wsse:BinarySecurityToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns2:LtdCompanyRequest">
<ns2:Control>
<ns1:AppName ">
SOFYCUK
</ns1:AppName>
<ns1:Consent">
YCON
</ns1:Consent>
<ns1:AppSrchType">
P
</ns1:AppSrchType>
</ns2:Control>
<ns2:RegNumber>
06954101
</ns2:RegNumber>
</ns2:LtdCompanyRequest>
</soapenv:Body>
</soapenv:Envelope>
What I have highlighted in yellow is what the provider call "Security Token" and here you have what exactly the provider says.
1. You should provide a request as the one above
2. Security Token (what I have highlighted) is taken from another Web Service which you should authenticate through certificate (this Web service was done by me and working fine as IŽm getting correctly the SecurityToken as String)
My first try before coming to this axis2 list was to develop the soap request and added the header with the Security token, obviusly I got exactly the same soap message as the one provided by the provider, but even that it didnŽt work.
My way to did it
//securityToken parameter is the String got from the Web Service which provide it as the authentication
// itŽs something like RXJyb3IgaXNzRqluZyBhdXRoAz50aWNhdG4vbi20b2tlbg== (this value is dummy as I have change it but lenght is the same)
private static void crearFirmaCabecera(LtdCompanySearchStub stub, String securityToken){
try {
String XMLNS_WSU = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
String XSD_WSSE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMElement omSecurityElement = omFactory.createOMElement(new QName(XSD_WSSE, "Security", "wsse"), null);
omSecurityElement.declareNamespace(XMLNS_WSU, "wsu");
OMElement omBinarySecurityToken = omFactory.createOMElement(new QName(XSD_WSSE, "BinarySecurityToken", "wsse"), null);
omBinarySecurityToken.addAttribute("xmlns:wsu", XMLNS_WSU, null);
omBinarySecurityToken.addAttribute("ValueType", "ExperianWASP",null);
omBinarySecurityToken.addAttribute("EncodingType", "wsse:Base64Binary",null);
omBinarySecurityToken.addAttribute("wsu:Id", "SecurityToken",null);
omBinarySecurityToken.setText(securityToken);
omSecurityElement.addChild(omBinarySecurityToken);
stub._getServiceClient().addHeader(omSecurityElement);
} catch (Throwable ex) {
System.out.println(ex);
}
}
Here I came to undertand how to retrieve the xml sent to check if ok. In the end I could verify it was the same but still didnŽt work.
I asked the provider and just said
Are you attaching the certificate as well as the token when you are
calling the service?
So not sure what it means to attach the certiicate. The communication with the provider is awful and the problem is not that IŽm Spanish and he speaks English.
Taking Martin example I try to use Rampart, and that is my challenge since Monday.
I have found on Internet a lot of examples about username and password within the header and it seems easy with rampart but about SecurityBinaryToken very very very few information or maybe for me itŽs not clear to understand.
So I tried Rampart and what I did is the following, I will try to go step by step and the best way is to go through my main class.
// I point to my local Axis configuration thatŽs why I create my context
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("E:\\orugama\\Software\\Windows\\Windows XP - 7\\Axis\\axis2-1.6.2\\repository",
"E:\\orugama\\Software\\Windows\\Windows XP - 7\\Axis\\axis2-1.6.2\\conf\\axis2.xml");
// I created stub with axis2 tools wsdl2java
stub = new com.experian.services.experian.wbsv.generic.bi.LtdCompanySearchStub(ctx, endpoint);
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
// proxy options not listed here but in my real code yes I have HTTPProxyProperties with correct values
options.setProperty(HTTPConstants.PROXY, HTTPProxyProperties);
RampartConfig rampartConfig = new RampartConfig();
rampartConfig.setUser("experian");
// I have created a PWCCallback as stated by Martin and will put later
rampartConfig.setPwCbClass("com.experian.uk.authenticator.PWCBHandler");
CryptoConfig sigCrypto = new CryptoConfig();
sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin");
Properties props = new Properties();
props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
// here is path to my keystore
props.setProperty("org.apache.ws.security.crypto.merlin.file","D:\\Netbeans\\ExperianWs\\certificado\\experian.jks");
props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "experian");
sigCrypto.setProp(props);
rampartConfig.setSigCryptoConfig(sigCrypto);
Policy policy = new Policy();
policy.addAssertion(rampartConfig);
client.engageModule("rampart");
client.getAxisService().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY, policy);
// here is where I call the web service
response = stub.limitedCompanyData(request); //and here I got java.lang.RuntimeException: Undefined 'Security policy namespace cannot be null.' resource property
Anyway my first attemp was to did the folowing
Policy policy = loadPolicy("D:\\Netbeans\\ExperianWs\\src\\policy.xml");
options.setProperty(RampartMessageData.KEY_RAMPART_OUT_POLICY, policy);
client.engageModule("rampart");
and my policy.xml was like this one
<wsp:Policy wsu:Id="SecurityToken" 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"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<sp:SupportingTokens
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<wsse:Security>
<wsse:BinarySecurityToken ValueType="ExperianWASP" EncodingType="wsse:Base64Binary" wsu:Id="SecurityToken"/>
</wsse:Security>
</wsp:Policy>
</sp:SupportingTokens>
<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:passwordCallbackClass>com.experian.uk.authenticator.PWCBHandler</ramp:passwordCallbackClass>
</ramp:RampartConfig>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
But in this case I check the xml sent and itŽs not correct
**************************************************************
My PWCHandler looks like this:
public class PWCBHandler implements CallbackHandler
{
public void handle(Callback[] callbacks) throws IOException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
if(pwcb.getIdentifier().equals("experian") ) {
// here not sure what to put as I donŽt understand exactly what this class is for
pwcb.setPassword("experian");
or
pwcb.setPassword(getSecurityBinaryTokenFromWebServiceWhichProvideIT());
return;
}
}
}
}
I wonder to understand how it works PWCBHandler .
I appreciate very much Martin efforts but as IŽm very new to rampart
Also I donŽt what to forget I tried to put InFlowConfiguration but it doesnŽt appear values like setPasswordType
See screenshot
I feel a little bit stupid as I have reading rampart examples and if I have to perform username and password toke for sure I can do but BinarySecurityToken as itŽs not a predefined type IŽm a bit lost.
DonŽt want to bother anyone but I have search in Google since Monday and tried several things until coming here right now and feeling stupid with no idea how to go on.
So any help trust me itŽs much appreciated.
And this for Martin and in Spanish.
Soy de Bilbao (España) por aquí las cosas no han ido muy bien por eso trabajo en Software y en una panadería pastelería.
Nosotros hacemos pan fresco y tenemos obrador de pastelería fresca diaria, todo lo que no es diario se tira a la basura para mantener nivel de calidad.
Eso si mi en mi caso concreto, a los niños pequeños les doy bollitos de pan gratis que les hace mucha ilusión y cuando digo niños pequeños, digo desde muy poquitos añitos para que muerdan y fortalezcan los dientes hasta alguno más mayorcito su sonrisa no tiene precio.
Pues aunque vivo en Bilbao, me toca trabajar mucho en Glasgow y aunque parezca mentira hay muchas probabilidades de que me toque trabajar en Méxcio y en Brasil el año que viene por lo que Martin si me toca expatriación ten por seguro que me moveré para compartir contigo unas cervezas.
gracias
Un saludo / Kind regards,
Oscar
From: ***@hotmail.com
To: java-***@axis.apache.org
Subject: RE: Log xml request file
Date: Sat, 7 Mar 2015 18:31:46 -0500
|_|
From: ***@hotmail.com
To: java-***@axis.apache.org
Subject: RE: Log xml request file
Date: Sat, 7 Mar 2015 10:35:01 +0100
Thank you very much, I will try Martin Rampart explanation on Monday, IŽm excitted to try now but on Saturday and Sunday I work in a Bakery and from Monday - Friday on Software
Keep all updated with my progress
MG>
Hay una panadería de la esquina en la casa de hija mia en América del sur.Pan fresco, Donuts y lo mejor de todo gratis trata a los niños...Si usted viaja a Colombia, Perú parada por UIO Ecuador...Yo recojo en el aeropuerto y llevarte a la panadería
Mantente en contacto porfavor
Muchismimas Gracias/Obrigrado,
Martín
MG>
Thank you very much
Kind regards,
Oscar
From: ***@hotmail.com
To: java-***@axis.apache.org
Subject: RE: Log xml request file
Date: Fri, 6 Mar 2015 22:08:09 -0500
Date: Fri, 6 Mar 2015 17:28:16 -0300
Subject: Re: Log xml request file
Post by Oscar RugamaSo because I have changed the soap header I want to know how exactly the
soap envelope will go I mean the soap request which is a xml file just to
compare with the structure I know that should be sent.
For me it is ok if something like system.out.printl(request) and appears in
the log the all soap request xml file
Does it make sense now?
Thanks your support is her appreciated.
Un saludo,
Oscar
MessageContext messageContext = MessageContext.
getCurrentMessageContext();
String request = messageContext.getEnvelope().toString();
- R
that will help for ADB ..thanks robert
for xmlbeans you may need to add log.debug statements in org.apache.axis2.xmlbeans.CodeGenerationUtility.java:
take a look at:
//process the unwrapped parameters
if (!cgconfig.isParametersWrapped()) {
//figure out the unwrapped operations
axisServices = cgconfig.getAxisServices();
for (Iterator servicesIter = axisServices.iterator(); servicesIter.hasNext();) {
axisService = (AxisService)servicesIter.next();
for (Iterator operations = axisService.getOperations();
operations.hasNext();) {
AxisOperation op = (AxisOperation)operations.next();
if (WSDLUtil.isInputPresentForMEP(op.getMessageExchangePattern())) {
AxisMessage message = op.getMessage(
WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (message != null &&
message.getParameter(Constants.UNWRAPPED_KEY) != null) {
SchemaGlobalElement xmlbeansElement =
sts.findElement(message.getElementQName());
log.debug("CodeGenerationUtility::processSchemas xmlbeansElement = "+xmlbeansElement.toString() );
then of course compile and redeploy:
mvn package
copy /target/*.jar into webapps/axis2/WEB-INF/lib
Un Saludo
Martín
---------------------------------------------------------------------