Correct use of SOAP WS services

2019-09-16 18:34发布

问题:

I'm deploying a SOAP WS service using AXIS2 as a framework on top of Tomcat.

package serverPerson;

public interface PersonService
{
    public Dipartimento getPersonInfo(Person p);

    public double multiply(float d1, float d2);
}

implementation:

package serverPerson;

public class PersonServiceImpl implements PersonService
{
 //method implementations omitted
}

I'm trying to use this services in the following way:

package com;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

import serverPerson.PersonService;

public class MainTest
{

    public static void main(String[] args)
    {
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(PersonService.class);
        factory.setAddress("http://localhost:82/PersonAxisServer/services/PersonServiceImpl.PersonServiceImplHttpSoap12Endpoint?wsdl");
        PersonService client = (PersonService) factory.create();

        double reply = client.multiply(2, 2);
        System.out.println("Server said: " + reply);

    }

}

But I always end up with the following exception:

Exception in thread "main" javax.xml.ws.WebServiceException: Could not find wsdl:binding operation info for web method multiply.
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:127)
    at com.sun.proxy.$Proxy19.multiply(Unknown Source)
    at com.MainTest.main(MainTest.java:17)

Do you have any idea what I'm doing wrong here?