Hi, I'm working on the "pojoguide" sample bundled with Axis2 1.1. I'm trying to expose WeatherService as a POJO service i.e. using WeatherService.java I run java2wsdl and generate the wsdl file.
I then use "XMLBeans" as databinding option for client code generation. When I try to compile the generated stub, I get the following error: /home/vvijayan/axis2-1.1/samples/pojoguide/build/client/src/sample/pojo/service/xmlbeans/WeatherServiceStub.java:203: missing return statement [javac] } [javac] ^ [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: /home/vvijayan/axis2-1.1/samples/pojoguide/build/client/src/sample/pojo/service/xmlbeans/WeatherServiceStub.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] 1 error BUILD FAILED When you look at the Stub code, you'll find that there are multiple instances of " //Unknown style detected !! No code is generated" comment. I've attached the wsdl and the stub code. Can anyone let me know the reason why I'm running into this issue. Thanks in advance. vedha -- Vedha Vijayan
<wsdl:definitions xmlns:axis2="http://service.pojo.sample" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns="http://service.pojo.sample/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.pojo.sample"><wsdl:types><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://data.pojo.sample/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://data.pojo.sample/xsd"> <xs:element name="Weather" type="ax21:Weather" /> <xs:complexType name="Weather"> <xs:sequence> <xs:element name="forecast" nillable="true" type="xs:string" /> <xs:element name="howMuchRain" type="xs:float" /> <xs:element name="rain" type="xs:boolean" /> <xs:element name="temperature" type="xs:float" /> </xs:sequence> </xs:complexType> </xs:schema><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://data.pojo.sample/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.pojo.sample/xsd"> <xs:element name="getWeatherResponse"> <xs:complexType> <xs:sequence> <xs:element name="return" nillable="true" type="ns0:Weather" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="setWeather"> <xs:complexType> <xs:sequence> <xs:element name="param0" nillable="true" type="ns0:Weather" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema></wsdl:types><wsdl:message name="getWeatherMessage" /><wsdl:message name="getWeatherResponseMessage"><wsdl:part name="part1" element="ns:getWeatherResponse" /></wsdl:message><wsdl:message name="setWeatherMessage"><wsdl:part name="part1" element="ns:setWeather" /></wsdl:message><wsdl:portType name="WeatherServicePortType"><wsdl:operation name="getWeather"><wsdl:input message="axis2:getWeatherMessage" /><wsdl:output message="axis2:getWeatherResponseMessage" /></wsdl:operation><wsdl:operation name="setWeather"><wsdl:input message="axis2:setWeatherMessage" /></wsdl:operation></wsdl:portType><wsdl:binding name="WeatherServiceSOAP11Binding" type="axis2:WeatherServicePortType"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="Document" /><wsdl:operation name="getWeather"><soap:operation soapAction="urn:getWeather" style="Document" /><wsdl:input><soap:body use="literal" namespace="http://service.pojo.sample" /></wsdl:input><wsdl:output><soap:body use="literal" namespace="http://service.pojo.sample" /></wsdl:output></wsdl:operation><wsdl:operation name="setWeather"><soap:operation soapAction="urn:setWeather" style="Document" /><wsdl:input><soap:body use="literal" namespace="http://service.pojo.sample" /></wsdl:input></wsdl:operation></wsdl:binding><wsdl:binding name="WeatherServiceSOAP12Binding" type="axis2:WeatherServicePortType"><soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="Document" /><wsdl:operation name="getWeather"><soap12:operation soapAction="urn:getWeather" style="Document" /><wsdl:input><soap12:body use="literal" namespace="http://service.pojo.sample" /></wsdl:input><wsdl:output><soap12:body use="literal" namespace="http://service.pojo.sample" /></wsdl:output></wsdl:operation><wsdl:operation name="setWeather"><soap12:operation soapAction="urn:setWeather" style="Document" /><wsdl:input><soap12:body use="literal" namespace="http://service.pojo.sample" /></wsdl:input></wsdl:operation></wsdl:binding><wsdl:service name="WeatherService"><wsdl:port name="WeatherServiceSOAP11port" binding="axis2:WeatherServiceSOAP11Binding"><soap:address location="http://localhost:8080/axis2/services/WeatherService" /></wsdl:port><wsdl:port name="WeatherServiceSOAP12port" binding="axis2:WeatherServiceSOAP12Binding"><soap12:address location="http://localhost:8080/axis2/services/WeatherService" /></wsdl:port></wsdl:service></wsdl:definitions>
services.xml
Description: application/xml
/** * WeatherServiceStub.java * * This file was auto-generated from WSDL * by the Apache Axis2 version: 1.1 Nov 13, 2006 (07:31:44 LKT) */ package sample.pojo.service.xmlbeans; /* * WeatherServiceStub java implementation */ public class WeatherServiceStub extends org.apache.axis2.client.Stub { protected org.apache.axis2.description.AxisOperation[] _operations; //hashmaps to keep the fault mapping private java.util.HashMap faultExeptionNameMap = new java.util.HashMap(); private java.util.HashMap faultExeptionClassNameMap = new java.util.HashMap(); private java.util.HashMap faultMessageMap = new java.util.HashMap(); private void populateAxisService() throws org.apache.axis2.AxisFault { //creating the Service with a unique name _service = new org.apache.axis2.description.AxisService("WeatherService" + this.hashCode()); //creating the operations org.apache.axis2.description.AxisOperation __operation; _operations = new org.apache.axis2.description.AxisOperation[2]; __operation = new org.apache.axis2.description.OutInAxisOperation(); __operation.setName(new javax.xml.namespace.QName("", "getWeather")); _service.addOperation(__operation); _operations[0]=__operation; __operation = new org.apache.axis2.description.OutOnlyAxisOperation(); __operation.setName(new javax.xml.namespace.QName("", "setWeather")); _service.addOperation(__operation); _operations[1]=__operation; } //populates the faults private void populateFaults(){ } /** Constructor that takes in a configContext */ public WeatherServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { //To populate AxisService populateAxisService(); populateFaults(); _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service); configurationContext = _serviceClient.getServiceContext().getConfigurationContext(); _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference( targetEndpoint)); //Set the soap version _serviceClient.getOptions().setSoapVersionURI(org.apache.axiom.soap.SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); } /** * Default Constructor */ public WeatherServiceStub() throws org.apache.axis2.AxisFault { this("http://localhost:8080/axis2/services/WeatherService" ); } /** * Constructor taking the target endpoint */ public WeatherServiceStub(java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { this(null,targetEndpoint); } /** * Auto generated method signature * @see sample.pojo.service.xmlbeans.WeatherService#getWeather */ public sample.pojo.service.xsd.GetWeatherResponseDocument getWeather( ) throws java.rmi.RemoteException { try{ org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("urn:getWeather"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); // create SOAP envelope with that payload org.apache.axiom.soap.SOAPEnvelope env = null; //Unknown style detected !! No code is generated //adding SOAP headers _serviceClient.addHeadersToEnvelope(env); // create message context with that soap envelope org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext() ; _messageContext.setEnvelope(env); // add the message contxt to the operation client _operationClient.addMessageContext(_messageContext); //execute the operation client _operationClient.execute(true); org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext( org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); //Unknown style detected !! No code is generated }catch(org.apache.axis2.AxisFault f){ org.apache.axiom.om.OMElement faultElt = f.getDetail(); if (faultElt!=null){ if (faultExeptionNameMap.containsKey(faultElt.getQName())){ //make the fault by reflection try{ java.lang.String exceptionClassName = (java.lang.String)faultExeptionClassNameMap.get(faultElt.getQName()); java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); java.lang.Exception ex= (java.lang.Exception) exceptionClass.newInstance(); //message class java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); java.lang.Class messageClass = java.lang.Class.forName(messageClassName); java.lang.Object messageObject = fromOM(faultElt,messageClass,null); java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", new java.lang.Class[]{messageClass}); m.invoke(ex,new java.lang.Object[]{messageObject}); throw new java.rmi.RemoteException(ex.getMessage(), ex); }catch(java.lang.ClassCastException e){ // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.ClassNotFoundException e) { // we cannot intantiate the class - throw the original Axis fault throw f; }catch (java.lang.NoSuchMethodException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.reflect.InvocationTargetException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.IllegalAccessException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.InstantiationException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } }else{ throw f; } }else{ throw f; } } } public void setWeather( sample.pojo.service.xsd.SetWeatherDocument param2 ) throws java.rmi.RemoteException { org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[1].getName()); _operationClient.getOptions().setAction("urn:setWeather"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); org.apache.axiom.soap.SOAPEnvelope env = null; //Unknown style detected !! No code is generated //adding SOAP headers _serviceClient.addHeadersToEnvelope(env); // create message context with that soap envelope org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext() ; _messageContext.setEnvelope(env); // add the message contxt to the operation client _operationClient.addMessageContext(_messageContext); _operationClient.execute(true); return; } /** * A utility method that copies the namepaces from the SOAPEnvelope */ private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env){ java.util.Map returnMap = new java.util.HashMap(); java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces(); while (namespaceIterator.hasNext()) { org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) namespaceIterator.next(); returnMap.put(ns.getPrefix(),ns.getNamespaceURI()); } return returnMap; } private javax.xml.namespace.QName[] opNameArray = null; private boolean optimizeContent(javax.xml.namespace.QName opName) { if (opNameArray == null) { return false; } for (int i = 0; i < opNameArray.length; i++) { if (opName.equals(opNameArray[i])) { return true; } } return false; } //http://localhost:8080/axis2/services/WeatherService private org.apache.axiom.om.OMElement toOM(sample.pojo.service.xsd.GetWeatherResponseDocument param, boolean optimizeContent){ org.apache.axiom.om.impl.builder.StAXOMBuilder builder = new org.apache.axiom.om.impl.builder.StAXOMBuilder (org.apache.axiom.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader())) ; org.apache.axiom.om.OMElement documentElement = builder.getDocumentElement(); ((org.apache.axiom.om.impl.OMNodeEx)documentElement).setParent(null); return documentElement; } private org.apache.axiom.om.OMElement toOM(sample.pojo.service.xsd.SetWeatherDocument param, boolean optimizeContent){ org.apache.axiom.om.impl.builder.StAXOMBuilder builder = new org.apache.axiom.om.impl.builder.StAXOMBuilder (org.apache.axiom.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader())) ; org.apache.axiom.om.OMElement documentElement = builder.getDocumentElement(); ((org.apache.axiom.om.impl.OMNodeEx)documentElement).setParent(null); return documentElement; } private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, sample.pojo.service.xsd.SetWeatherDocument param, boolean optimizeContent){ org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope(); if (param != null){ envelope.getBody().addChild(toOM(param, optimizeContent)); } return envelope; } /** * get the default envelope */ private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){ return factory.getDefaultEnvelope(); } public org.apache.xmlbeans.XmlObject fromOM( org.apache.axiom.om.OMElement param, java.lang.Class type, java.util.Map extraNamespaces){ try{ if (sample.pojo.service.xsd.GetWeatherResponseDocument.class.equals(type)){ if (extraNamespaces!=null){ return sample.pojo.service.xsd.GetWeatherResponseDocument.Factory.parse( param.getXMLStreamReaderWithoutCaching(), new org.apache.xmlbeans.XmlOptions().setLoadAdditionalNamespaces(extraNamespaces)); }else{ return sample.pojo.service.xsd.GetWeatherResponseDocument.Factory.parse( param.getXMLStreamReaderWithoutCaching()); } } if (sample.pojo.service.xsd.SetWeatherDocument.class.equals(type)){ if (extraNamespaces!=null){ return sample.pojo.service.xsd.SetWeatherDocument.Factory.parse( param.getXMLStreamReaderWithoutCaching(), new org.apache.xmlbeans.XmlOptions().setLoadAdditionalNamespaces(extraNamespaces)); }else{ return sample.pojo.service.xsd.SetWeatherDocument.Factory.parse( param.getXMLStreamReaderWithoutCaching()); } } }catch(java.lang.Exception e){ throw new RuntimeException("Data binding error",e); } return null; } private void setOpNameArray(){ opNameArray = null; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]