Thank you for your example. They are very useful. :-) Thanks again
Sincerely Dacheng ----- Original Message ----- From: "Adrian Perez Jorge" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 21, 2004 4:05 PM Subject: Re: How to publish two class with one WSDL? > Dacheng wrote: > > >Can you do me a favor to give me an example? > > > > > > > Sure. I have included ClassA and ClassB source code as examples. > Command lines follows. > > a) put .java files in src/ directory and compile source samples from > src/ directory to build/ directory, incluing debug information: > > javac -g -d build src/test/*.java > > b) generate WSDL for ClassA: > > java -cp $CLASSPATH:build org.apache.axis.wsdl.Java2WSDL -o > serviceA.wsdl -l"http://localhost/axis/services/serviceA" test.ClassA > > c) generate WSDL for ClassB merging ClassB's WSDL: > > java -cp $CLASSPATH:build org.apache.axis.wsdl.Java2WSDL -o > serviceB.wsdl --input=serviceA.wsdl > -l"http://localhost/axis/services/serviceB" test.ClassB > > I have included both wsdl files. The one you would like to publish is > serviceB.wsdl. You can override the WSDL file that axis serves when > using "?wsdl" url queries, so instead of generating the wsdl for each > request you can tell axis to return serviceB.wsdl. Check out this URL > for that: > > http://www.osmoticweb.com/axis-wsdd/wsdlFile.htm > > Hope that helped. > > Adrian P.J. > > >Cheers > > > >Dacheng > > > > > > ---------------------------------------------------------------------------- ---- > package test; > > public class ClassA { > > public Integer methodA(Integer i) { > > return new Integer(i.intValue() + 1); > } > } > ---------------------------------------------------------------------------- ---- > package test; > > public class ClassB { > > public String methodB(String s) { > > return s + "a"; > } > } > ---------------------------------------------------------------------------- ---- > <?xml version="1.0" encoding="UTF-8"?> > <wsdl:definitions targetNamespace="http://test" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://test" xmlns:intf="http://test" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > <wsdl:message name="methodAResponse"> > > <wsdl:part name="methodAReturn" type="xsd:int"/> > > </wsdl:message> > > <wsdl:message name="methodARequest"> > > <wsdl:part name="i" type="xsd:int"/> > > </wsdl:message> > > <wsdl:portType name="ClassA"> > > <wsdl:operation name="methodA" parameterOrder="i"> > > <wsdl:input message="intf:methodARequest" name="methodARequest"/> > > <wsdl:output message="intf:methodAResponse" name="methodAResponse"/> > > </wsdl:operation> > > </wsdl:portType> > > <wsdl:binding name="serviceASoapBinding" type="intf:ClassA"> > > <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> > > <wsdl:operation name="methodA"> > > <wsdlsoap:operation soapAction=""/> > > <wsdl:input name="methodARequest"> > > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test" use="encoded"/> > > </wsdl:input> > > <wsdl:output name="methodAResponse"> > > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test" use="encoded"/> > > </wsdl:output> > > </wsdl:operation> > > </wsdl:binding> > > <wsdl:service name="ClassAService"> > > <wsdl:port binding="intf:serviceASoapBinding" name="serviceA"> > > <wsdlsoap:address location="http://localhost/axis/services/servic eA"/> > > </wsdl:port> > > </wsdl:service> > > </wsdl:definitions> > ---------------------------------------------------------------------------- ---- > <?xml version="1.0" encoding="UTF-8"?> > <wsdl:definitions targetNamespace="http://test" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://test" xmlns:intf="http://test" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > <wsdl:message name="methodARequest"> > > <wsdl:part name="i" type="xsd:int"/> > > </wsdl:message> > > <wsdl:message name="methodAResponse"> > > <wsdl:part name="methodAReturn" type="xsd:int"/> > > </wsdl:message> > > <wsdl:message name="methodBResponse"> > > <wsdl:part name="methodBReturn" type="xsd:string"/> > > </wsdl:message> > > <wsdl:message name="methodBRequest"> > > <wsdl:part name="s" type="xsd:string"/> > > </wsdl:message> > > <wsdl:portType name="ClassB"> > > <wsdl:operation name="methodB" parameterOrder="s"> > > <wsdl:input message="intf:methodBRequest" name="methodBRequest"/> > > <wsdl:output message="intf:methodBResponse" name="methodBResponse"/> > > </wsdl:operation> > > </wsdl:portType> > > <wsdl:portType name="ClassA"> > > <wsdl:operation name="methodA" parameterOrder="i"> > > <wsdl:input message="intf:methodARequest" name="methodARequest"/> > > <wsdl:output message="intf:methodAResponse" name="methodAResponse"/> > > </wsdl:operation> > > </wsdl:portType> > > <wsdl:binding name="serviceASoapBinding" type="intf:ClassA"> > > <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> > > <wsdl:operation name="methodA"> > > <wsdlsoap:operation soapAction=""/> > > <wsdl:input name="methodARequest"> > > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test" use="encoded"/> > > </wsdl:input> > > <wsdl:output name="methodAResponse"> > > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test" use="encoded"/> > > </wsdl:output> > > </wsdl:operation> > > </wsdl:binding> > > <wsdl:binding name="serviceBSoapBinding" type="intf:ClassB"> > > <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> > > <wsdl:operation name="methodB"> > > <wsdlsoap:operation soapAction=""/> > > <wsdl:input name="methodBRequest"> > > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test" use="encoded"/> > > </wsdl:input> > > <wsdl:output name="methodBResponse"> > > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test" use="encoded"/> > > </wsdl:output> > > </wsdl:operation> > > </wsdl:binding> > > <wsdl:service name="ClassAService"> > > <wsdl:port binding="intf:serviceASoapBinding" name="serviceA"> > > <wsdlsoap:address location="http://localhost/axis/services/serviceA"/> > > </wsdl:port> > > </wsdl:service> > > <wsdl:service name="ClassBService"> > > <wsdl:port binding="intf:serviceBSoapBinding" name="serviceB"> > > <wsdlsoap:address location="http://localhost/axis/services/serviceB"/> > > </wsdl:port> > > </wsdl:service> > > </wsdl:definitions> >