<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://example.com/HelloWorldService" xmlns:tns="http://example.com/HelloWorldService" name="HelloWorldService"> <types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/HelloWorldService" xmlns:tns="http://example.com/HelloWorldService"> <xs:element name="sayHelloRequest"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="sayHelloResponse"> <xs:complexType> <xs:sequence> <xs:element name="message" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </types> <message name="sayHelloRequest"> <part name="parameters" element="tns:sayHelloRequest" /> </message> <message name="sayHelloResponse"> <part name="parameters" element="tns:sayHelloResponse" /> </message> <portType name="HelloWorldPortType"> <operation name="sayHello"> <input message="tns:sayHelloRequest" /> <output message="tns:sayHelloResponse" /> </operation> </portType> <binding name="HelloWorldBinding" type="tns:HelloWorldPortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="sayHello"> <soap:operation soapAction="http://example.com/HelloWorldService/sayHello" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <service name="HelloWorldService"> <port name="HelloWorldPort" binding="tns:HelloWorldBinding"> <soap:address location="http://example.com/HelloWorld" /> </port> </service> </definitions> import javax.wsdl.*; import javax.wsdl.factory.*; import javax.wsdl.xml.*; class WSDLGenerator { public static void main(String[] args) { try { WSDLFactory factory = WSDLFactory.newInstance(); WSDLReader reader = factory.newWSDLReader(); Definition definition = reader.readWSDL("path/to/your/wsdl/file.wsdl"); WSDLWriter writer = factory.newWSDLWriter(); writer.writeWSDL(definition, System.out); } catch (Exception e) { e.printStackTrace(); } } }


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