import javax.wsdl.*; import javax.wsdl.factory.*; import javax.wsdl.xml.*; import org.apache.axis.client.Service; public class WSDL4JExample { public static void main(String[] args) throws WSDLException { DefinitionFactory factory = new WSDLFactoryImpl(); WSDLReader reader = factory.newWSDLReader(); Definition definition = reader.readWSDL("http://example.com/your-wsdl-url"); Service service = (Service) definition.getServices().values().iterator().next(); Port port = (Port) service.getPorts().values().iterator().next(); try { ServiceLocator locator = new ServiceLocator(); YourWebServiceInterface serviceInterface = locator.getYourWebServiceInterface(port.getBinding().getPortType().getQName()); } catch (Exception e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文