31 Mayıs 2018 Perşembe

JAX-WS @WebService Anostasyonu

Giriş
Şu satırı dahil ederiz.
import javax.jws.WebService;
@WebMethod,@WebParam,@ WebResult gibi anotasyonlarla beraber kullanıldığı için şu satırı dahil ederiz.
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
Standalone Deployment
Endpoint.publish metodu kullanılır.

endPointInterface Alanı
Şöyle yaparız.
@WebService(endpointInterface = "com.enterprise.ws.WebServiceInterface")
public class WebServiceImpl implements WebServiceInterface {

  @Resource
  WebServiceContext webServiceContext;

  @Override
  public String getHelloWorldAsString(String str) {
    ...
    return "...";
   
  }
}
name Alanı
Şöyle yaparız.
@WebService(targetNamespace = "asd:asd", name = "MyServiceInterface")
@XmlSeeAlso({asd.asd.ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface MyServiceInterface {

    @WebMethod(operationName = "Operation", action = "asd:asd:#Operation")
    @WebResult(name = "OperationResponse", targetNamespace = "asd:asd",
      partName = "OperationResponseBody")
    public asd.asd.OperationResponseType operation(
        @WebParam(partName = "OperationBody",
                  name = "DateSinceStart",
                  targetNamespace = "asd:asd")
        @XmlJavaTypeAdapter(Adapter1.class)
        java.time.LocalDateTime operationBody
    );
}
serviceName Alanı
Şöyle yaparız.
@WebService(serviceName="MyWebService",
            portName="MyWebServicePort",
            endpointInterface="com.abc.MyWebService",
            targetNamespace="http://abc.com")
public class MyWebService implements MyWebServiceInterface {...}
targetNamespace Alanı
Şöyle yaparız
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


@WebService(targetNamespace = "http://aa.com/FareFilingService/", name = "FareFiling")
@XmlSeeAlso({com.aa.farefilling.to.ObjectFactory.class, ObjectFactory.class})
public interface FareFiling {

  @WebMethod
  @RequestWrapper(localName = "fileFare", 
    targetNamespace = "http://aa.com/FareFilingService/",
    className = "com.aa.farefilingservice.FileFare")
  @ResponseWrapper(localName = "fileFareResponse", 
    targetNamespace = "http://aa.com/FareFilingService/",
    className = "com.aa.farefilingservice.FileFareResponse")
  @WebResult(name = "fareResponse", targetNamespace = "")
  public com.aa.farefilling.to.FareResponse[] fileFare(
    @WebParam(name = "fareData", targetNamespace = "")
    com.aa.farefilling.to.FareData fareData
  ) throws FileFareFault;
}




Hiç yorum yok:

Yorum Gönder