Java API发布Web Service步骤

1.定义服务接口

 

package com.test.soap;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@WebService
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface MessageReceiver
{
    public String receiveMessage(String message);
}

 2.定义服务实现类

 

package com.test.soap;

import javax.jws.WebService;

@WebService(endpointInterface = "com.test.soap.MessageReceiver", serviceName = "MessageReceiver")
public class MessageReceiverImpl implements MessageReceiver
{
    @Override
    public String receiveMessage(String message)
    {
        return "have received!";
    }
}

 3.发布服务

 

package com.test.soap;

import javax.xml.ws.Endpoint;

public class Server
{
    public static void main(String args[])
    {
        MessageReceiver implementor = new MessageReceiverImpl();
        String address = "http://10.0.0.46:9000/messageReceiver";
        Endpoint.publish(address, implementor);
    }
}

 4.在浏览器输入http://10.0.0.46:9000/messageReceiver?wsdl看到wsdl文档则发布成功。

你可能感兴趣的:(java,Web,浏览器,webservice,SOAP)