Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Invoking SOAP Web Services inside AEM OSGI Service Using Apache-CFX | AEM Community Blog Seeding

Avatar

Administrator

1612838616345.png

Invoking SOAP Web Services inside AEM OSGI Service Using Apache-CFX by Navin Kaushal

Abstract

Introduction:
Recently, I was struggling to invoke SOAP WebService inside an OSGI Service in AEM. I tried to search however there was not a single article or tutorial I could find to refer to. I thought it would be good to provide some steps around this. I could not make this an extensive article with a lot of information and code samples however, this could be a good starting point for others.

Step -1: Setup AEM Project Structure:
Create an AEM Project which has an OSGI Service implemented. Here is the Sample code

// Service Interface
public interface SoapClient {
public String greetMe(String name);
}


// Service Interface Implementation Class
@Component(service = SoapClient.class, immediate = true, configurationPid = "com.api.connector.service.impl.SoapClient", property = {
Constants.SERVICE_DESCRIPTION + "=SOAP Client Service Interface",
"label" + "=SOAP Client Service Interface",
"service.ranking:Integer=10",
})


@Designate(ocd=SoapClientConfig.class)
public class SoapClientImpl implements SoapClient {


private static final Logger log = LoggerFactory.getLogger(SoapClientImpl.class);


@WebServiceRef(wsdlLocation = "http://www.examples.com/wsdl/HelloService.wsdl")
private HelloService serviceObj;

public BMSAPIWrapperImpl() {

if (SoapClientImpl == null) {
log.info("Service not found hence being created.");
try {
URL myWSDLURL = new URL("http://www.examples.com/wsdl/HelloService.wsdl");
this.serviceObj = new HelloService(myWSDLURL);
log.info("Service created successfully.");
} catch (Exception e) {
log.info("Service not created Error : "+e.getMessage());
}
}
}

//
public String greetMe(String name) {

IHelloService endPoint = serviceObj.getServiceEndPoint(); // get the endPoint of the service - generated by WSDL2JAVA Utility
endPoint.greetMe(name); // Invoke GreetMe Method
}
}



Step -2: Generate Java Classes from WSDL
Generate Java Classes from your WSDL using the WSDL2JAVA Utility. You may use the following command

wsdl2java -verbose -d folderNameWhereJavaFilesGenerated http://www.examples.com/wsdl/HelloService.wsdl

Step -3: Copy all the Generated JAVA files
Copy all the Generated JAVA files inside your AEM OSGI Project

Step -4: Install Apache-CFX Runtime dependency
Download Apache-CFX from this URL and install it to your AEM Instance using package explorer.

Read Full Blog

Invoking SOAP Web Services inside AEM OSGI Service Using Apache-CFX

Q&A

Please use this thread to ask the related questions.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies