Tuesday, November 16, 2010

AXIS2/JAVA client code for basic authentication with SSL

EndpointReference targetEPR1 = new EndpointReference("https://your URL");
XMLStreamReader parser = XMLInputFactory.newInstance()
.createXMLStreamReader(new FileReader("E:\\DartMouth\\Version2\\V3\\Test\\SOAPEnvelope"));
System.out.println("aaaa "+parser.getVersion());
OMXMLParserWrapper wrapper = new StAXSOAPModelBuilder(parser);

ServiceClient sc = new ServiceClient();

Options options = new Options();
options.setTo(targetEPR1);

//authentication
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername("username");
basicAuth.setPassword("pwd");
options.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);


options.setAction("soap_action");
System.setProperty("javax.net.ssl.trustStore","path to truststore\\test.jks");
System.setProperty("javax.net.ssl.trustStorePassword","test123");
sc.setOptions(options);
OperationClient res = sc.createClient(ServiceClient.ANON_OUT_IN_OP);
MessageContext mc = new MessageContext();
SOAPFactory sf = OMAbstractFactory.getSOAP11Factory();

mc.setEnvelope((SOAPEnvelope)wrapper.getDocumentElement());
res.addMessageContext(mc);
res.execute(true);
MessageContext outMsgtCtx = res.getMessageContext("In");
System.out.println("results "+outMsgtCtx.getEnvelope().toString());

Friday, October 1, 2010

WSDL Validator

It happens often when we want to validate WSDL. Though lot of online tools are available but we cannot expose our WSDL to internet. Other tools we have to buy to use. Eclipse plug is a good option though.

Recently I cam across WSDL validator by apache CXF. Which can be run through command prompt and take WSDL as param.

This should be a must have tool for webservice developer.

Saturday, August 14, 2010

Opening class file present in JAR

Often it happens that you just have jar files without source code and you want to investigate a class present in jar file. It's really easy in eclipse provided you have already installed JAD plugin for eclipse.

What you have to do is not ctr+shift+r but ctr+shift+t and give the class name you want to visit. You should be able to see decompiled class using JAD eclipse plugin.

Monday, August 2, 2010

Remote debugging with Tomcat 6 and Eclipse

Life as a developer is so easier if you know this. What it meant is debugging the code running on another JVM in tomcat. lets see how to configure.
You don't have to make any changes in catalina.bat in bin folder if its tomcat 6. For tomcat 6 default jpda(java platform debugging architecture) port is 8000. So go to the your eclipse and navigate to debug menu. Select Remote java application. Click on new to create new configuration. In project select project you want to debug. In host select host where tomcat is running and port will be JPDA port(In this case 8000). Hit apply and then hit debug. Set your break point. Go to bin folder of tomcat and execute following command to start tomcat.

catalina jpda start

Your are good to go.

Wednesday, July 28, 2010

Encoding string to base64 encoded value

Quite simple if you have notepad++. Select the text you want to encode. Go plugins > mime tools > Base64 encode. You are done :-)