I have exposed SOAP webservice using JAX-WS in java. Following is the code snippet:
package com.soap.calculator;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class Calci {
@WebMethod
public int add(int x, int y){
return x+y;
}
@WebMethod
public int subtract(int x, int y){
return x-y;
}
}
Following is code snippet for publishing this webservice:
package com.soap.calculator;
import javax.xml.ws.Endpoint;
public class Server {
public static void main(String agrs[]){
Endpoint ep = Endpoint.publish("http://localhost:8081/SoapwebService", new Calci());
System.out.println("Service created");
}
}
I am using jQuery plugin for communicating with this webservice using SOAP.Since this webservice is exposed on some other domain, browser is enabled in CORS mode and generating preflight request for accessing web service. My question is How to enable CORS support on server side using jax-ws?