User authentication in SOAP Webservices

JAAS does not define how the authentication information should look like in SOAP, but WS-Security defines what kind of standardized tokens you can use during client-server exchange (Username+password token / X.509 certificate / SAML token / Kerberos Token). EDIT: With respect to Metro WebService stack, you need (steps taken from here and here): Inject the … Read more

Java web service without a web application server

You don’t need a third party library to use jax-ws annotations. J2SE ships with jax-ws, so all the annotations are still available to you. You can achieve lightweight results with the following solution, but for anything optimized/multi-threaded, it’s on your own head to implement: Design a SEI, service endpoint interface, which is basically a java … Read more

Add SOAP header object using pure JAX-WS

So, it looks like I’ve found possible answer while combining JAX-WS & JAXB related answers from SO (I would really appreciate if somebody experienced in these technologies can check whether following is correct): The obvious thing for me is to add SOAP message handler and alter header of SOAPMessage instance in it: import javax.xml.ws.Binding; import … Read more

RESTful webservice : how to set headers in java to accept XMLHttpRequest allowed by Access-Control-Allow-Origin

Read here about your issue CORS : http://enable-cors.org/ Check if this one help you in your getMsg() method: return Response.ok(output).header(“Access-Control-Allow-Origin”, “*”).build(); If above doesn’t work try to add Jersey filter to your service. Create filter class: package your.package; public class CORSFilter implements ContainerResponseFilter { @Override public ContainerResponse filter(ContainerRequest creq, ContainerResponse cresp) { cresp.getHttpHeaders().putSingle(“Access-Control-Allow-Origin”, “*”); cresp.getHttpHeaders().putSingle(“Access-Control-Allow-Credentials”, … Read more

How to make generated classes contain Javadoc from XML Schema documentation

I’ve never been able to get regular xsd:documentation to be placed in the java source except if and only if it was a Complex Type. Documentation for elements, simple types, etc are ignored. So, I end up using jxb:javadoc. To do so, include the definition of xmlns:jxb=”http://java.sun.com/xml/ns/jaxb” in your <xsd:schema> element. Add a child to … Read more

overriding or setting web service endpoint at runtime for code generated with wsimport

Your client can set the end-point in the service “port” at runtime via the BindingProvider interface. Consider the JAX-WS client in this JAX-WS tutorial. Another way to write this code would be: HelloService service = new HelloService(); Hello port = service.getHelloPort(); BindingProvider bindingProvider = (BindingProvider) port; bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, “http://foo:8086/HelloWhatever”); String response = port.sayHello(name); Caveat: I … Read more

Changing the default XML namespace prefix generated with JAXWS

Maybe it’s late for you and I’m not sure if this may work, but you can try. First you need to implement a SoapHandler and, in the handleMessage method you can modify the SOAPMessage. I’m not sure if you can modify directly that prefix but you can try: public class MySoapHandler implements SOAPHandler<SOAPMessageContext> { @Override … Read more

JAX-WS Loading WSDL from jar

Yes this is most definitely possible as I have done it when creating clients through javax.xml.ws.EndpointReference, a WS-A related class. I have added a classpath reference to the WSDL to the WS-A EndPointReference and the Metro implementation of JAX-WS loaded it just fine. Whether loading the WSDL from the WS-A EndPointReference or from a file … Read more