I needed to add WEB-INF\server-config.wsdd and add my custom services in that file. After that, I was able to see my custom service. I was able to create custom client and successfully returned the results.
There is so much emphasis on deploying using JWS, Admin Console etc. and a lot of emphasis on Tomcat. I wish there were more documentations on steps needed to be taken for app servers other than Tomcat. mule_user wrote: > > I am new to Axis. I am using Axis 1 (not Axis2). I am trying to make a > simple app work. I created a web project called Axis1 which has two modles > namely Axis1(which only has META-INF\application.xml) and Axis1Web. > Axis1Web has the source code. > > > > Axis1Web > | > ---META-INF > | > ----application.xml > > <?xml version="1.0" encoding="UTF-8"?> > <application id="Application_ID" version="1.4" > xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> > <display-name> > Axis1</display-name> > <module id="WebModule_1255025189235"> > <web> > <web-uri>Axis1Web.war</web-uri> > <context-root>Axis1Web</context-root> > </web> > </module> > </application> > > > > Axis1Web > | > ----src > | > -----org.ncc.server > | | > | ----Calculator > | | > | ----SimpleCalculator > | > -----org.ncc.client (contains code geberated by WSDL2Java) > | > ----Axis1WebSoapBindingStub > | > ----Calculator > | > ----CalculatorService > | > ----CalculatorServiceLocator > | > ----CalcCleint (written by me, not generated by WSDl2Java) > > > Axis1Web project's WEB-INF\lib contains all the jar files from lib > directory of Axis 1 (version 1.4). That is why wsdl2Java generated classes > comiple successfully. > > Axis1Web\WebContent\WEB-INF\web.xml > > //////////////////////////////// > <?xml version="1.0" encoding="UTF-8"?> > <web-app id="WebApp_ID" version="2.4" > xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> > <display-name> > Axis1Web</display-name> > </web-app> > ///////////////////////////////// > > Interface in server package: > ///////////////////////// > package org.ncc.server; > > public interface Calculator { > int add (int x, int y); > } > ///////////////////////// > > Implementation in server package: > //////////////////////// > package org.ncc.server; > > public class SimpleCalculator { > public int add(int a, int b) { > return a + b; > } > } > ///////////////////////////// > I copied Calculator.class to C:\Axis. Then I ran the following to generate > Java2WSDL. > > > C:\Axis>set > CLASSPATH=%AXIS_CLASSPATH%;C:\workspace-7.5\Axis1Web\WebContent\WEB- > INF\classes > > C:\Axis>java -classpath %CLASSPATH% org.apache.axis.wsdl.Java2WSDL -o > calculator > .wsdl -n urn:org.ncc.calculator -l http://localhost:9081/Axis1Web > org.ncc.server > .Calculator > > > Generated C:\Axis\claculator.wsdl is: > ///////////////////////////// > <?xml version="1.0" encoding="UTF-8"?> > <wsdl:definitions targetNamespace="urn:org.ncc.calculator" > xmlns:apachesoap="http://xml.apache.org/xml-soap" > xmlns:impl="urn:org.ncc.calculator" xmlns:intf="urn:org.ncc.calculator" > 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 created by Apache Axis version: 1.4 > Built on Apr 22, 2006 (06:55:48 PDT)--> > > <wsdl:message name="addResponse"> > > <wsdl:part name="addReturn" type="xsd:int"/> > > </wsdl:message> > > <wsdl:message name="addRequest"> > > <wsdl:part name="in0" type="xsd:int"/> > > <wsdl:part name="in1" type="xsd:int"/> > > </wsdl:message> > > <wsdl:portType name="Calculator"> > > <wsdl:operation name="add" parameterOrder="in0 in1"> > > <wsdl:input message="impl:addRequest" name="addRequest"/> > > <wsdl:output message="impl:addResponse" name="addResponse"/> > > </wsdl:operation> > > </wsdl:portType> > > <wsdl:binding name="Axis1WebSoapBinding" type="impl:Calculator"> > > <wsdlsoap:binding style="rpc" > transport="http://schemas.xmlsoap.org/soap/http"/> > > <wsdl:operation name="add"> > > <wsdlsoap:operation soapAction=""/> > > <wsdl:input name="addRequest"> > > <wsdlsoap:body > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > namespace="urn:org.ncc.calculator" use="encoded"/> > > </wsdl:input> > > <wsdl:output name="addResponse"> > > <wsdlsoap:body > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > namespace="urn:org.ncc.calculator" use="encoded"/> > > </wsdl:output> > > </wsdl:operation> > > </wsdl:binding> > > <wsdl:service name="CalculatorService"> > > <wsdl:port binding="impl:Axis1WebSoapBinding" name="Axis1Web"> > > <wsdlsoap:address location="http://localhost:9081/Axis1Web"/> > > </wsdl:port> > > </wsdl:service> > > </wsdl:definitions> > ///////////////////////////// > > Next, I ran WSDL2Java > > C:\Axis>java org.apache.axis.wsdl.WSDL2Java calculator.wsdl > > > This generated 4 classes in C:\Axis. I copy these 4 classes to > org.ncc.client package, changed package name inside the classes, compiled > these 4 classes. Classes in client package after successful compiling are > shown below: > > ///////////////////////////// > package org.ncc.client; > > public interface Calculator extends java.rmi.Remote { > public int add(int in0, int in1) throws java.rmi.RemoteException; > } > ///////////////////// > package org.ncc.client; > > public interface CalculatorService extends javax.xml.rpc.Service { > public java.lang.String getAxis1WebAddress(); > public org.ncc.client.Calculator getAxis1Web() throws > javax.xml.rpc.ServiceException; > public org.ncc.client.Calculator getAxis1Web(java.net.URL portAddress) > throws javax.xml.rpc.ServiceException; > } > ///////////////////////// > > package org.ncc.client; > > public class CalculatorServiceLocator extends > org.apache.axis.client.Service implements org.ncc.client.CalculatorService > { > > public CalculatorServiceLocator() { > } > > public CalculatorServiceLocator(org.apache.axis.EngineConfiguration > config) { > super(config); > } > > public CalculatorServiceLocator(java.lang.String wsdlLoc, > javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { > super(wsdlLoc, sName); > } > > // Use to get a proxy class for Axis1Web > private java.lang.String Axis1Web_address = > "http://localhost:9081/Axis1Web"; > > public java.lang.String getAxis1WebAddress() { > return Axis1Web_address; > } > > // The WSDD service name defaults to the port name. > private java.lang.String Axis1WebWSDDServiceName = "Axis1Web"; > > public java.lang.String getAxis1WebWSDDServiceName() { > return Axis1WebWSDDServiceName; > } > > public void setAxis1WebWSDDServiceName(java.lang.String name) { > Axis1WebWSDDServiceName = name; > } > > public org.ncc.client.Calculator getAxis1Web() throws > javax.xml.rpc.ServiceException { > java.net.URL endpoint; > try { > endpoint = new java.net.URL(Axis1Web_address); > } > catch (java.net.MalformedURLException e) { > throw new javax.xml.rpc.ServiceException(e); > } > return getAxis1Web(endpoint); > } > > public org.ncc.client.Calculator getAxis1Web(java.net.URL portAddress) > throws javax.xml.rpc.ServiceException { > try { > org.ncc.client.Axis1WebSoapBindingStub _stub = new > org.ncc.client.Axis1WebSoapBindingStub(portAddress, this); > _stub.setPortName(getAxis1WebWSDDServiceName()); > return _stub; > } > catch (org.apache.axis.AxisFault e) { > return null; > } > } > > public void setAxis1WebEndpointAddress(java.lang.String address) { > Axis1Web_address = address; > } > > /** > * 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 > (org.ncc.client.Calculator.class.isAssignableFrom(serviceEndpointInterface)) > { > org.ncc.client.Axis1WebSoapBindingStub _stub = new > org.ncc.client.Axis1WebSoapBindingStub(new java.net.URL(Axis1Web_address), > this); > _stub.setPortName(getAxis1WebWSDDServiceName()); > 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); > } > java.lang.String inputPortName = portName.getLocalPart(); > if ("Axis1Web".equals(inputPortName)) { > return getAxis1Web(); > } > 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("urn:org.ncc.calculator", > "CalculatorService"); > } > > 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("urn:org.ncc.calculator", "Axis1Web")); > } > return ports.iterator(); > } > > /** > * Set the endpoint address for the specified port name. > */ > public void setEndpointAddress(java.lang.String portName, > java.lang.String address) throws javax.xml.rpc.ServiceException { > > if ("Axis1Web".equals(portName)) { > setAxis1WebEndpointAddress(address); > } > else > { // Unknown Port Name > throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint > Address for Unknown Port" + portName); > } > } > > /** > * Set the endpoint address for the specified port name. > */ > public void setEndpointAddress(javax.xml.namespace.QName portName, > java.lang.String address) throws javax.xml.rpc.ServiceException { > setEndpointAddress(portName.getLocalPart(), address); > } > } > /////////////////////////////////// > > package org.ncc.client; > > public class Axis1WebSoapBindingStub extends org.apache.axis.client.Stub > implements org.ncc.client.Calculator { > 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]; > _initOperationDesc1(); > } > > private static void _initOperationDesc1(){ > org.apache.axis.description.OperationDesc oper; > org.apache.axis.description.ParameterDesc param; > oper = new org.apache.axis.description.OperationDesc(); > oper.setName("add"); > param = new org.apache.axis.description.ParameterDesc(new > javax.xml.namespace.QName("", "in0"), > org.apache.axis.description.ParameterDesc.IN, new > javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), > int.class, false, false); > oper.addParameter(param); > param = new org.apache.axis.description.ParameterDesc(new > javax.xml.namespace.QName("", "in1"), > org.apache.axis.description.ParameterDesc.IN, new > javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), > int.class, false, false); > oper.addParameter(param); > oper.setReturnType(new > javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); > oper.setReturnClass(int.class); > oper.setReturnQName(new javax.xml.namespace.QName("", > "addReturn")); > oper.setStyle(org.apache.axis.constants.Style.RPC); > oper.setUse(org.apache.axis.constants.Use.ENCODED); > _operations[0] = oper; > > } > > public Axis1WebSoapBindingStub() throws org.apache.axis.AxisFault { > this(null); > } > > public Axis1WebSoapBindingStub(java.net.URL endpointURL, > javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { > this(service); > super.cachedEndpoint = endpointURL; > } > > public Axis1WebSoapBindingStub(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; > } > > ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); > } > > protected org.apache.axis.client.Call createCall() throws > java.rmi.RemoteException { > try { > org.apache.axis.client.Call _call = super._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)); > } > return _call; > } > catch (java.lang.Throwable _t) { > throw new org.apache.axis.AxisFault("Failure trying to get the > Call object", _t); > } > } > > public int add(int in0, int in1) 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(""); > > _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); > _call.setOperationName(new > javax.xml.namespace.QName("urn:org.ncc.calculator", "add")); > > setRequestHeaders(_call); > setAttachments(_call); > try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] > {new java.lang.Integer(in0), new java.lang.Integer(in1)}); > > if (_resp instanceof java.rmi.RemoteException) { > throw (java.rmi.RemoteException)_resp; > } > else { > extractAttachments(_call); > try { > return ((java.lang.Integer) _resp).intValue(); > } catch (java.lang.Exception _exception) { > return ((java.lang.Integer) > org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue(); > } > } > } catch (org.apache.axis.AxisFault axisFaultException) { > throw axisFaultException; > } > } > > } > ////////////////////////////////// > > I create a EAR file out of Axis1 application and successfully deploy it in > App Server (WebSphere 6.1 test server that comes bundled with RAD 7.5). > The Axis1 application also successfully get started. The console shows > that the application (Axis1) and the web module (Axis1Web) is successfully > started. I can also view the index.html (placed under > Axis1Web\WebContentent\index.html)successfully as: > http://localhost:9081/Axis1Web/index.html > > /////////////////////////////// > [10/8/09 16:48:40:469 EDT] 0000001e ApplicationMg A WSVR0200I: Starting > application: Axis1 > [10/8/09 16:48:40:469 EDT] 0000001e ApplicationMg A WSVR0204I: > Application: Axis1 Application build level: Unknown > [10/8/09 16:48:40:657 EDT] 0000001e WebGroup A SRVE0169I: Loading > Web Module: Axis1Web. > [10/8/09 16:48:40:688 EDT] 0000001e VirtualHost I SRVE0250I: Web > Module Axis1Web has been bound to > default_host[*:9081,*:80,*:9444,*:5060,*:5061,*:443]. > [10/8/09 16:48:40:704 EDT] 0000001e ApplicationMg A WSVR0221I: > Application started: Axis1 > > ////////////////////////////////// > > My client code, that I wrote myself to invoke the web service is: > > //////////////////// > package org.ncc.client; > > public class CalcClient { > > public static void main(String[] args) throws Exception { > CalculatorService service = new CalculatorServiceLocator(); > > Calculator calc = service.getAxis1Web(); > int ret = calc.add(1, 2); > System.out.println(ret); > } > } > ////////////////////////////// > > [b]When I run CalcClient on the server (WebSphere test server 6.1, that > comes bundled with RAD 7.5) that is already running. When I run the code, > I get error as:[/b] > > //////////////////////////// > Exception in thread "main" AxisFault > faultCode: > {http://schemas.xmlsoap.org/soap/envelope/}Server.userException > faultSubcode: > faultString: org.xml.sax.SAXParseException: Content is not allowed in > prolog. > faultActor: > faultNode: > faultDetail: > {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: > Content is not allowed in prolog. > at > org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown > Source) > at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) > at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) > at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) > at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) > at > org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) > at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) > at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) > at > org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) > at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) > at org.apache.axis.client.Call.invokeEngine(Call.java:2784) > at org.apache.axis.client.Call.invoke(Call.java:2767) > at org.apache.axis.client.Call.invoke(Call.java:2443) > at org.apache.axis.client.Call.invoke(Call.java:2366) > at org.apache.axis.client.Call.invoke(Call.java:1812) > at > org.ncc.client.Axis1WebSoapBindingStub.add(Axis1WebSoapBindingStub.java:105) > at org.ncc.client.CalcClient.main(CalcClient.java:8) > > {http://xml.apache.org/axis/}hostname:TCD-108078 > > org.xml.sax.SAXParseException: Content is not allowed in prolog. > at org.apache.axis.AxisFault.makeFault(AxisFault.java:101) > at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701) > > //////////////////////////// > > When I debug through the code, I get exception thrown from > org.ncc.client.Axis1WebSoapBindingStub in line: > /////////////////////// > > java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new > java.lang.Integer(in0), new java.lang.Integer(in1)}); > ///////////////////////////// > > The value of _call variable in org.ncc.client.Axis1WebSoapBindingStub > (right before attempting to execute the line shown above) is: > > /////////////////////// > operation > > name: add > returnQName: addReturn > returnType: {http://www.w3.org/2001/XMLSchema}int > returnClass: int > elementQName:null > soapAction: null > style: rpc > use: encoded > numInParams: 2 > method:null > ParameterDesc[0]: > name: in0 > typeEntry: null > mode: IN > position: 0 > isReturn: false > typeQName: {http://www.w3.org/2001/XMLSchema}int > javaType: int > inHeader: false > outHeader: false > > ParameterDesc[1]: > name: in1 > typeEntry: null > mode: IN > position: 1 > isReturn: false > typeQName: {http://www.w3.org/2001/XMLSchema}int > javaType: int > inHeader: false > outHeader: false > > /////////////////// > operationName > > {urn:org.ncc.calculator}add > > ////////// > portName > > Axis1Web > > ////////// > timeout > > null > > ///////////// > service > > org.ncc.client.calculatorserviceloca...@25422542 > > ////////////// > password > > null > ///////////// > transport > > org.apache.axis.transport.http.httptransp...@3ee03ee0 > > //////////////////////// > > > Even though the name of the project is Axis, I changed the endpoint to > Axis1Web thinking that the source code is in Axis1Web project, not in > Axis1. The port number is 9081 (for those who are not familiar with > WebSphere) and is correctly specified. > > My guess is that I am doing something incorrect while specifying > parameters during Java2WSDL, or WSDL2Java. > > Or, my client code might be incorrect. > > Any help will be appreciated. > > Also, I would like it to be running as Axis1 (not Axis2) application. And, > I will deploy this application as an EAR file instead of using Axis Admin > console. > > As such, please foucs your comments with reference to Axis1 and deployment > as an EAR file. > > -- View this message in context: http://www.nabble.com/Axis-1-%281.4%29---Simple-proof-of-concept-client-not-working---SAXParserException%3A-Content-is-not-allowed-in-prolog-tp25812054p25827301.html Sent from the Axis - User mailing list archive at Nabble.com.