So just to be clear, you have your own Web service that you want to run and test as well, right? If this is the case, there are a few more targets that you will need to get the web service built and deployed in axis. There are also a list of steps to go through to get everything working. There are critical points that you have to restart your server and then register the web service with deploy.wsdd files. If this is the case, I can send you more examples of this - just let me know.
Ken > -----Original Message----- > From: Tom Sturgeon [mailto:[EMAIL PROTECTED] > Sent: Thursday, May 20, 2004 10:14 AM > To: [EMAIL PROTECTED] > Subject: RE: Step By Step Example > > > Is this any different for a SOAP service? > > My stub names are different than the example (which was > excellent and got me light years from where I was.) > > My service only has one function, getCounts() (which returns > the XML doc at the bottom). > > Here are my client (and stub files): > * > @author Tom Sturgeon > */ > > package client; > > import stubs.*; > > > public class ClientService1Stub { > > /** > * main method is what is called first. > */ > public static void main(String[] args) throws Exception { > Service1Locator serviceLocator = new Service1Locator(); > Service1SoapStub stub = > (Service1SoapStub)serviceLocator.getPort(); > > String temp = stub.getCounts(); > > > } > } > > /** > * Service1.java > * > * This file was auto-generated from WSDL > * by the Apache Axis WSDL2Java emitter. > */ > > package stubs; > > public interface Service1 extends javax.xml.rpc.Service { > public java.lang.String getService1SoapAddress(); > > public stubs.Service1Soap getService1Soap() throws > javax.xml.rpc.ServiceException; > > public stubs.Service1Soap getService1Soap(java.net.URL > portAddress) throws javax.xml.rpc.ServiceException; } > > /** > * Service1Locator.java > * > * This file was auto-generated from WSDL > * by the Apache Axis WSDL2Java emitter. > */ > > package stubs; > > public class Service1Locator extends > org.apache.axis.client.Service implements stubs.Service1 { > > // Use to get a proxy class for Service1Soap > private final java.lang.String Service1Soap_address = > "http://localhost/WebService1/Service1.asmx"; > > public java.lang.String getService1SoapAddress() { > return Service1Soap_address; > } > > // The WSDD service name defaults to the port name. > private java.lang.String Service1SoapWSDDServiceName = > "Service1Soap"; > > public java.lang.String getService1SoapWSDDServiceName() { > return Service1SoapWSDDServiceName; > } > > public void > setService1SoapWSDDServiceName(java.lang.String name) { > Service1SoapWSDDServiceName = name; > } > > public stubs.Service1Soap getService1Soap() throws > javax.xml.rpc.ServiceException { > java.net.URL endpoint; > try { > endpoint = new java.net.URL(Service1Soap_address); > } > catch (java.net.MalformedURLException e) { > throw new javax.xml.rpc.ServiceException(e); > } > return getService1Soap(endpoint); > } > > public stubs.Service1Soap getService1Soap(java.net.URL > portAddress) throws javax.xml.rpc.ServiceException { > try { > stubs.Service1SoapStub _stub = new > stubs.Service1SoapStub(portAddress, this); > _stub.setPortName(getService1SoapWSDDServiceName()); > return _stub; > } > catch (org.apache.axis.AxisFault e) { > return null; > } > } > > /** > * For the given interface, get the stub implementation. > * If this service has no port for the given interface, > * then ServiceException is thrown. > */ > public java.rmi.Remote getPort(Class > serviceEndpointInterface) throws javax.xml.rpc.ServiceException { > try { > if > (stubs.Service1Soap.class.isAssignableFrom(serviceEndpointInte > rface)) { > stubs.Service1SoapStub _stub = new > stubs.Service1SoapStub(new java.net.URL(Service1Soap_address), this); > _stub.setPortName(getService1SoapWSDDServiceName()); > return _stub; > } > } > catch (java.lang.Throwable t) { > throw new javax.xml.rpc.ServiceException(t); > } > throw new javax.xml.rpc.ServiceException("There is no > stub implementation for the interface: " + > (serviceEndpointInterface == null ? "null" : > serviceEndpointInterface.getName())); > } > > /** > * For the given interface, get the stub implementation. > * If this service has no port for the given interface, > * then ServiceException is thrown. > */ > public java.rmi.Remote getPort(javax.xml.namespace.QName > portName, Class serviceEndpointInterface) throws > javax.xml.rpc.ServiceException { > if (portName == null) { > return getPort(serviceEndpointInterface); > } > String inputPortName = portName.getLocalPart(); > if ("Service1Soap".equals(inputPortName)) { > return getService1Soap(); > } > else { > java.rmi.Remote _stub = getPort(serviceEndpointInterface); > ((org.apache.axis.client.Stub) > _stub).setPortName(portName); > return _stub; > } > } > > public javax.xml.namespace.QName getServiceName() { > return new > javax.xml.namespace.QName("http://www.persystent.com/webservices/", > "Service1"); > } > > private java.util.HashSet ports = null; > > public java.util.Iterator getPorts() { > if (ports == null) { > ports = new java.util.HashSet(); > ports.add(new javax.xml.namespace.QName("Service1Soap")); > } > return ports.iterator(); > } > > } > > /** > * Service1Soap.java > * > * This file was auto-generated from WSDL > * by the Apache Axis WSDL2Java emitter. > */ > > package stubs; > > public interface Service1Soap extends java.rmi.Remote { > public stubs._GetCountsResponse_GetCountsResult > getCounts() throws java.rmi.RemoteException; } > > /** > * Service1SoapStub.java > * > * This file was auto-generated from WSDL > * by the Apache Axis WSDL2Java emitter. > */ > > package stubs; > > public class Service1SoapStub extends > org.apache.axis.client.Stub implements stubs.Service1Soap { > private java.util.Vector cachedSerClasses = new > java.util.Vector(); > private java.util.Vector cachedSerQNames = new java.util.Vector(); > private java.util.Vector cachedSerFactories = new > java.util.Vector(); > private java.util.Vector cachedDeserFactories = new > java.util.Vector(); > > static org.apache.axis.description.OperationDesc [] _operations; > > static { > _operations = new > org.apache.axis.description.OperationDesc[1]; > org.apache.axis.description.OperationDesc oper; > oper = new org.apache.axis.description.OperationDesc(); > oper.setName("GetCounts"); > oper.setReturnType(new > javax.xml.namespace.QName("http://www.persystent.com/webservices/", > ">GetCountsResponse>GetCountsResult")); > > oper.setReturnClass(stubs._GetCountsResponse_GetCountsResult.class); > oper.setReturnQName(new > javax.xml.namespace.QName("http://www.persystent.com/webservices/", > "GetCountsResult")); > oper.setStyle(org.apache.axis.enum.Style.WRAPPED); > oper.setUse(org.apache.axis.enum.Use.LITERAL); > _operations[0] = oper; > > } > > public Service1SoapStub() throws org.apache.axis.AxisFault { > this(null); > } > > public Service1SoapStub(java.net.URL endpointURL, > javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { > this(service); > super.cachedEndpoint = endpointURL; > } > > public Service1SoapStub(javax.xml.rpc.Service service) > throws org.apache.axis.AxisFault { > if (service == null) { > super.service = new org.apache.axis.client.Service(); > } else { > super.service = service; > } > java.lang.Class cls; > javax.xml.namespace.QName qName; > java.lang.Class beansf = > org.apache.axis.encoding.ser.BeanSerializerFactory.class; > java.lang.Class beandf = > org.apache.axis.encoding.ser.BeanDeserializerFactory.class; > java.lang.Class enumsf = > org.apache.axis.encoding.ser.EnumSerializerFactory.class; > java.lang.Class enumdf = > org.apache.axis.encoding.ser.EnumDeserializerFactory.class; > java.lang.Class arraysf = > org.apache.axis.encoding.ser.ArraySerializerFactory.class; > java.lang.Class arraydf = > org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; > java.lang.Class simplesf = > org.apache.axis.encoding.ser.SimpleSerializerFactory.class; > java.lang.Class simpledf = > org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; > qName = new > javax.xml.namespace.QName("http://www.persystent.com/webservices/", > ">GetCountsResponse>GetCountsResult"); > cachedSerQNames.add(qName); > cls = stubs._GetCountsResponse_GetCountsResult.class; > cachedSerClasses.add(cls); > cachedSerFactories.add(beansf); > cachedDeserFactories.add(beandf); > > } > > private org.apache.axis.client.Call createCall() throws > java.rmi.RemoteException { > try { > org.apache.axis.client.Call _call = > (org.apache.axis.client.Call) > super.service.createCall(); > if (super.maintainSessionSet) { > _call.setMaintainSession(super.maintainSession); > } > if (super.cachedUsername != null) { > _call.setUsername(super.cachedUsername); > } > if (super.cachedPassword != null) { > _call.setPassword(super.cachedPassword); > } > if (super.cachedEndpoint != null) { > _call.setTargetEndpointAddress(super.cachedEndpoint); > } > if (super.cachedTimeout != null) { > _call.setTimeout(super.cachedTimeout); > } > if (super.cachedPortName != null) { > _call.setPortName(super.cachedPortName); > } > java.util.Enumeration keys = > super.cachedProperties.keys(); > while (keys.hasMoreElements()) { > java.lang.String key = (java.lang.String) > keys.nextElement(); > _call.setProperty(key, > super.cachedProperties.get(key)); > } > // All the type mapping information is registered > // when the first call is made. > // The type mapping information is actually registered in > // the TypeMappingRegistry of the service, which > // is the reason why registration is only needed > for the first call. > synchronized (this) { > if (firstCall()) { > // must set encoding style before > registering serializers > _call.setEncodingStyle(null); > for (int i = 0; i < > cachedSerFactories.size(); ++i) { > java.lang.Class cls = > (java.lang.Class) cachedSerClasses.get(i); > javax.xml.namespace.QName qName = > (javax.xml.namespace.QName) > cachedSerQNames.get(i); > java.lang.Class sf = (java.lang.Class) > cachedSerFactories.get(i); > java.lang.Class df = (java.lang.Class) > cachedDeserFactories.get(i); > _call.registerTypeMapping(cls, qName, > sf, df, false); > } > } > } > return _call; > } > catch (java.lang.Throwable t) { > throw new org.apache.axis.AxisFault("Failure > trying to get the Call object", t); > } > } > > public stubs._GetCountsResponse_GetCountsResult > getCounts() throws java.rmi.RemoteException { > if (super.cachedEndpoint == null) { > throw new org.apache.axis.NoEndPointException(); > } > org.apache.axis.client.Call _call = createCall(); > _call.setOperation(_operations[0]); > _call.setUseSOAPAction(true); > > _call.setSOAPActionURI("http://www.persystent.com/webservices/ > GetCounts" > ); > _call.setEncodingStyle(null); > _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, > Boolean.FALSE); > _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, > Boolean.FALSE); > > _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11 > _CONSTANTS > ); > _call.setOperationName(new > javax.xml.namespace.QName("http://www.persystent.com/webservices/", > "GetCounts")); > > setRequestHeaders(_call); > setAttachments(_call); > java.lang.Object _resp = _call.invoke(new > java.lang.Object[] {}); > > if (_resp instanceof java.rmi.RemoteException) { > throw (java.rmi.RemoteException)_resp; > } > else { > extractAttachments(_call); > try { > return > (stubs._GetCountsResponse_GetCountsResult) _resp; > } catch (java.lang.Exception _exception) { > return (stubs._GetCountsResponse_GetCountsResult) > org.apache.axis.utils.JavaUtils.convert(_resp, > stubs._GetCountsResponse_GetCountsResult.class); > } > } > } > > } > > <?xml version="1.0" encoding="utf-8" ?> > - <DataSet xmlns="http://www.persystent.com/webservices/"> > - <xs:schema id="DataSet1" > targetNamespace="http://www.tempuri.org/DataSet1.xsd" > xmlns:mstns="http://www.tempuri.org/DataSet1.xsd" > xmlns="http://www.tempuri.org/DataSet1.xsd" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" > attributeFormDefault="qualified" elementFormDefault="qualified"> > - <xs:element name="DataSet1" msdata:IsDataSet="true"> > - <xs:complexType> > - <xs:choice maxOccurs="unbounded"> > - <xs:element name="tblnodemst"> > - <xs:complexType> > - <xs:sequence> > <xs:element name="NMRebootCount" type="xs:int" minOccurs="0" /> > <xs:element name="NMHealCount" type="xs:int" minOccurs="0" /> > <xs:element name="NMAlias" type="xs:string" /> > <xs:element name="NMId" msdata:ReadOnly="true" > msdata:AutoIncrement="true" type="xs:int" /> > <xs:element name="NMMacAddr" type="xs:string" /> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:choice> > </xs:complexType> > - <xs:unique name="Constraint1" msdata:PrimaryKey="true"> > <xs:selector xpath=".//mstns:tblnodemst" /> > <xs:field xpath="mstns:NMId" /> > </xs:unique> > </xs:element> > </xs:schema> > - <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" > xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> > - <DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd"> > - <tblnodemst diffgr:id="tblnodemst1" msdata:rowOrder="0"> > <NMRebootCount>1</NMRebootCount> > <NMHealCount>7</NMHealCount> > <NMAlias>1INODEPC-06</NMAlias> > <NMId>34</NMId> > <NMMacAddr>000BDB583C72</NMMacAddr> > </tblnodemst> > - <tblnodemst diffgr:id="tblnodemst2" msdata:rowOrder="1"> > <NMRebootCount>1</NMRebootCount> > <NMHealCount>29</NMHealCount> > <NMAlias>inodepc-05</NMAlias> > <NMId>40</NMId> > <NMMacAddr>000bdbc6b66d</NMMacAddr> > </tblnodemst> > - <tblnodemst diffgr:id="tblnodemst3" msdata:rowOrder="2"> > <NMAlias>12BuckleMyShoe</NMAlias> > <NMId>38</NMId> > <NMMacAddr>098765432123</NMMacAddr> > </tblnodemst> > - <tblnodemst diffgr:id="tblnodemst4" msdata:rowOrder="3"> > <NMAlias>Arun</NMAlias> > <NMId>39</NMId> > <NMMacAddr>000bdb589a3c</NMMacAddr> > </tblnodemst> > </DataSet1> > </diffgr:diffgram> > </DataSet> > > -----Original Message----- > From: Lee, Ken [mailto:[EMAIL PROTECTED] > Sent: Thursday, May 20, 2004 11:54 AM > To: [EMAIL PROTECTED] > Subject: RE: Step By Step Example > > > In my build stubs tasks I have the following, and indeed the > > stubs are built. > > > > However, no classes are generated, nor source for the > > classes: <java classname="org.apache.axis.wsdl.WSDL2Java" > fork="yes"> > > <arg value="-o"/> > > <arg value="${src.dir}"/> > > <arg value="${conf.dir}/Service1.wsdl"/> > > <arg value="-p"/> > > <arg value="stubs"/> > > <classpath> > > <path refid="axis.libraries"/> > > </classpath> > > </java> > > </target> > > > The example was designed for working with an existing Web > service, such as the examples on xmethods... With that being said - > > When you run "ant compile", there is a dependency on stubs > and stubs depends on clean. Clean wipes out the classes and > build directories (The build directories are not even used in > this case.) When the code above gets run, if in the conf.dir > location, you have a wsdl file named Service1.wsdl, then > stubs wil be created. The four java files will be created in > the stubs directory under source. That's what the above says > - build and put the java files in the stubs package/directory. > > The next dependency is compile that was in the build file. > Those lines > were: > <javac srcdir="${src.dir}/stubs" > destdir="${classes.dir}" fork="true"> > <classpath> > <path refid="all"/> > </classpath> > </javac> > > <javac srcdir="${src.dir}/client" > destdir="${classes.dir}" fork="true"> > <classpath> > <path refid="all"/> > </classpath> > </javac> > > This will compile the source in the src/stubs directory and > in the src/client directory. You will find the classes in > the classes\stubs and classes\client directories. > > > Now off to running the example - > > > > This is in the compile task. Where do the name and classname > > come from, and how does that relate to above: <target > > name="clientService1stub.run" description="Run Service1 Stub"> > > <java classname="client.ClientService1Stub" fork="yes"> > > <classpath> > > <path refid="all"/> > > </classpath> > > </java> > > </target> > > The target is just what is called after the run command. > So... ant clientServicestub1.run > > This will run the class file ClientService1Stub that iws in > the client package/directory. I am assuming that use created > a file classed ClientService1Stub.java that is a copy of the > other examples. After you ran ant compile the first time, > you will see the stub files that are available in the > src\stub directory. Changing the names in the client is > pretty straight forward. > > TemperatureServiceLocator serviceLocator = new > TemperatureServiceLocator(); TemperatureBindingStub stub = > (TemperatureBindingStub)serviceLocator.getTemperaturePort(); > > In this case the word "Temperature" would be exchanged for > your service name. The only tricky part that I have run in to is the > getTemperaturePort() function may be different. This is > specific to each web service. This call can be found in the > <name>ServiceLocator.java code. > > > Hope this gets you closer. > > Thanks, > > Ken > > > >