繁体   English   中英

有人可以提供带有wsdl文件的示例SOAP WSDL Web服务示例

[英]Can someone give sample SOAP WSDL webservice with wsdl file

我需要使用wsdl文件创建soap服务器,并允许我的客户端将webservice与非wsdl模式的soap客户端一起使用。

如果有人可以发布示例工作Web服务代码,我将不胜感激。 我在使用非wsdl soap客户端时遇到问题。 在stackoverflow上没有人可以回答我以前的问题,所以我现在要询问示例代码。

lets go, This is a sample hello world soap web service program, Go through the program,  if u doesn't understand anything ask me ...

actually, there are few styles available in soap binding, here i have used the rpc

    package com.kowthal.ws;

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

    //Service Endpoint Interface
    @WebService
    @SOAPBinding(style = Style.RPC)
    public interface HelloWorld{

        @WebMethod String getHelloWorldAsString(String name);
     }


This is for implementation panel, the returned value will be mapped in soap webservice call
   package com.kowthal.ws;

    import javax.jws.WebService;

    //Service Implementation
    @WebService(endpointInterface = "com.kowthal.ws.HelloWorld")
    public class HelloWorldImpl implements HelloWorld{

        @Override
        public String getHelloWorldAsString(String name) {
            return "soap done by " + name;
        }

    }

this is the endpoint, here i had bind the data with specific url please note down the packages

    package com.kowthal.endpoint;

    import javax.xml.ws.Endpoint;
    import com.kowthal.ws.HelloWorldImpl;

    //Endpoint publisher
    public class HelloWorldPublisher{

        public static void main(String[] args) {
           Endpoint.publish[juz tag]("http://localhost:9988/ws/hello", new HelloWorldImpl());
        }

    }

This one is for client side communication

    package com.kowthal.client;

    import java.net.URL;
    import javax.xml.namespace.QName;
    import javax.xml.ws.Service;
    import com.kowthal.ws.HelloWorld;

    public class HelloWorldClient{
        public static void main(String[] args) throws Exception {
     URL url = new URL[juz tag]("http://localhost:9988/ws/hello?wsdl");
           QName qname = new QName[juz tag]("http://ws.kowthal.com/", "HelloWorldImplService");
                Service service = Service.create(url, qname);
                HelloWorld hello = service.getPort(HelloWorld.class);
                System.out.println(hello.getHelloWorldAsString("kowthal"));
            }

        }

after that using this url u can retrive the xml data
[juz tag]"http://localhost:9988/ws/hello?wsdl"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM