JAX-WS web service on Weblogic 12c
Below I am posting links to post the web service.
http://www.mkyong.com/webservices/jax-ws/jax-ws-java-web-application-integration-example/ http://stlarch.blogspot.com.tr/2013/02/building-jax- ws-webservices-in-weblogic.html http://www.mkyong.com/webservices/jax-ws/jax-ws-spring-integration-example/ http://examples.javacodegeeks.com/enterprise-java/jws / jax-ws-spring-integration-example /
This code works when deployed to Tomcat. But this doesn't work in weblogic 12c. Do I need to provide additional parameters? I have no exception when deploying. I cannot see any single web console under Webservices in the deployed application.
UPDATE: After deploying the madhava encoded webservicetest.war
source to share
I read the following link and applied the display method servlet
. I can access wsdl
and make a successful request SOAP
viaSOAPUI
http://www.krestjaninoff.ru/2013/09/custom-context-path-for-jax-ws-web.html
<servlet>
<servlet-name>TestWSPort</servlet-name>
<display-name>TestWSPort</display-name>
<servlet-class>name.krestjaninoff.TestWSService</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestWSPort</servlet-name>
<url-pattern>myOwn/path/TestWS</url-pattern>
</servlet-mapping>
Here is the project I created, you can download https://www.dropbox.com/s/vztkfqxekw43n4a/WeblogicJaxWsProject.zip?dl=0
Thank you, Mikhail Krestyaninov, who is the owner of the post linked above
source to share
I created my own application to check your problem. Indeed it works great for me. I share the same with you.
1) Create a simple web application. (In Eclipse File + New + Dynamic Web Project)
2) Create the interface as a web service.
package com.madhava.service;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import com.madhava.CalculatorServiceConstant;
@WebService(name = CalculatorServiceConstant.Name.CALCULATOR_SERVICE, targetNamespace = CalculatorServiceConstant.CALCULATOR_SERVICE_TARGET_NAME_SPACE)
public interface CalculatorService {
@WebMethod
@WebResult(name="sum")Integer addNumber(@WebParam(name = "number1") Integer number1,
@WebParam(name = "number2") Integer number2);
@WebMethod
@WebResult(name="difference")Integer subtractNumber(@WebParam(name = "number1") Integer number1,
@WebParam(name = "number2") Integer number2);
@WebMethod
@WebResult(name="multiplication")Long multiplyNumber(@WebParam(name = "number1") Integer number1,
@WebParam(name = "number2") Integer number2);
@WebMethod
@WebResult(name="division")Double divideNumber(@WebParam(name = "number1") Integer number1,
@WebParam(name = "number2") Integer number2);
}
3) Create a class that implements the web service you wrote.
import javax.ejb.Stateless;
import javax.jws.WebService;
import com.madhava.service.CalculatorService;
@Stateless
@WebService(portName = CalculatorServiceConstant.PortName.CALCULATOR_SERVICE, serviceName = CalculatorServiceConstant.ServiceName.CALCULATOR_SERVICE, endpointInterface = CalculatorServiceConstant.EndPointInterface.CALCULATOR_SERVICE, targetNamespace = CalculatorServiceConstant.CALCULATOR_SERVICE_TARGET_NAME_SPACE)
public class CalculatorServiceImpl implements CalculatorService {
@Override
public Integer addNumber(Integer number1, Integer number2) {
if (number1 != null && number2 != null) {
return number1 + number2;
} else {
return 0;
}
}
@Override
public Integer subtractNumber(Integer number1, Integer number2) {
if (number1 != null && number2 != null) {
if (number1 > number2) {
return number1 - number2;
} else {
return number2 - number1;
}
} else {
return 0;
}
}
@Override
public Long multiplyNumber(Integer number1, Integer number2) {
if (number1 != null && number2 != null) {
return (long) (number1 * number2);
} else {
return 0L;
}
}
@Override
public Double divideNumber(Integer number1, Integer number2) {
if ((number1 != null && number2 != null) || number2!=0) {
return (double) (number1 / number2);
}
else {
return 0.0D;
}
}
}
4) Create a class that will store the name, port name, service name, etc.
public class CalculatorServiceConstant {
public static final String CALCULATOR_SERVICE_TARGET_NAME_SPACE = "http://calculatorservices.madhava.com";
private CalculatorServiceConstant() {
}
public static class Name {
public static final String CALCULATOR_SERVICE = "CalculatorService";
// Private Constructor
private Name() {
}
}
public static class PortName {
public static final String CALCULATOR_SERVICE = "CalculatorServicePort";
// Private Constructor
private PortName() {
}
}
public static class ServiceName {
public static final String CALCULATOR_SERVICE = "CalculatorServiceService";
// Private Constructor
private ServiceName() {
}
}
public static class EndPointInterface {
public static final String CALCULATOR_SERVICE = "com.madhava.service.CalculatorService";
// Private Constructor
private EndPointInterface() {
}
}
public static class JNDI {
public static final String CALCULATOR_SERVICE = "CalculatorService#com.madhava.service.CalculatorService";
// Private Constructor
private JNDI() {
}
}
}
5) Create a war application file and deploy to weblogic server. Here you can see the web service as "CalculatorServiceService"
Url for client verification in weblogic:
http://localhost:7001/wls_utc/?wsdlUrl=http%3A%2F%2Flocalhost%3A7001%2FWebServicesTest%2FCalculatorServiceService%3FWSDL
6) Finally, to test if it is working correctly or not, I created a client class.
package com.madhava.client;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import com.madhava.CalculatorServiceConstant;
import com.madhava.service.CalculatorService;
public class CalculatorServiceClient {
/**
* @param args
* @throws MalformedURLException
*/
public static void main(String[] args) throws MalformedURLException {
URL url = new URL("http://localhost:7001/WebServicesTest/CalculatorServiceService?wsdl");
QName qname = new QName(CalculatorServiceConstant.CALCULATOR_SERVICE_TARGET_NAME_SPACE, CalculatorServiceConstant.ServiceName.CALCULATOR_SERVICE);
Service service = Service.create(url, qname);
CalculatorService calculatorService = service.getPort(CalculatorService.class);
System.out.println(calculatorService.addNumber(10,20));
}
}
Hope this helps you!
source to share