SmdService.java 3.2 KB
package StSys.RoyoTech;

import com.myproject.util.DateUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
import java.util.Date;

/**
 * Created by sunke on 2019/10/22.
 */
@WebService(name = "IWSInterface", targetNamespace = "RoyoTech.StSys")
@Service
public class SmdService {
    protected final transient Logger log = LogManager.getLogger(getClass());

    @Autowired
    private ServiceHandle serviceHandle;

    @WebMethod(operationName = "WebServiceIsConnected", action = "RoyoTech.StSys/IWSInterface/WebServiceIsConnected")
    @WebResult(name = "WebServiceIsConnectedResult", targetNamespace = "RoyoTech.StSys")
    //@RequestWrapper(localName = "WebServiceIsConnected", targetNamespace = "RoyoTech.StSys", className = "example.client.WebServiceIsConnected")
    //@ResponseWrapper(localName = "WebServiceIsConnectedResponse", targetNamespace = "RoyoTech.StSys", className = "example.client.WebServiceIsConnectedResponse")
    public Boolean WebServiceIsConnected() {
        //log.info("WebServiceIsConnected");
        return true;
    }

    @WebMethod(operationName = "XmlAction", action = "RoyoTech.StSys/IWSInterface/XmlAction")
    @WebResult(name = "XmlActionResult", targetNamespace = "RoyoTech.StSys")
    //@RequestWrapper(localName = "XmlAction", targetNamespace = "RoyoTech.StSys", className = "example.client.XmlAction")
    //@ResponseWrapper(localName = "XmlActionResponse", targetNamespace = "RoyoTech.StSys", className = "example.client.XmlActionResponse")
    //@Action(input = "RoyoTech.StSys/IWSInterface/XmlAction", output = "RoyoTech.StSys/IWSInterface/XmlActionResponse")
    public XmlResultWrapper XmlAction(@WebParam(name = "xmlData", targetNamespace = "RoyoTech.StSys")
                                      String xmlData) {
        log.info("receive service cmd:" + xmlData);
        if(xmlData == null){
            xmlData = "";
        }
        XmlResultWrapper wrapper = new XmlResultWrapper();
        if(serviceHandle != null){
            wrapper.XmlResult = serviceHandle.handleCommand(xmlData);
        }
        return wrapper;
    }

    public static void main(String[] argv) {
        SmdService service = new SmdService();
        ServiceHandle handle = new ServiceHandle();
        service.serviceHandle = handle;

        String address = "http://10.42.73.173:8080/services/SmdService";
        address = "http://0.0.0.0:8888/services/SmdService";
        System.out.println("Publish the webservice, address:" + address);
        Endpoint.publish(address, service);

//        String posName = "3_2_1";
//        String cid = "06001";
//        String[] infos = posName.split("_");
//        if(infos.length >= 3){
//            String last = infos[infos.length-1];
//            String middle = infos[infos.length -2];
//            String first = infos[infos.length - 3];
//            String Depot = "T" + cid + "." + first + middle + last;
//            System.out.println(Depot);
//        }
    }

}