dal sito di Apache (http://ws.apache.org/wss4j/axis.html) ed ho una strana eccezione che non
riesco a capire al momento dell'esecuzione del client di test per il web service.
Premetto che sulla mia macchina ho installato Axis 1.2 Final come richiesto dal tutorial ed
ho anche le librerie aggiuntive come richiesto:
* Found IBM's WSDL4Java ( com.ibm.wsdl.factory.WSDLFactoryImpl ) at C:\Programmi\Apache
Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar
...
* Found XML Security API ( org.apache.xml.security.Init ) at C:\Programmi\Apache
Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\xmlsec.jar
* Found Java Secure Socket Extension ( javax.net.ssl.SSLSocketFactory ) at an unknown
location
Ecco come ho proceduto:
1. Ho realizzato il file deploy.wsdd
2. lìho effettuato il deploycodice:<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="stock-wss-01" provider="java:RPC" style="document" use="literal"> <parameter name="className" value="samples.stock.StockQuoteService"/> <parameter name="allowedMethods" value="getQuote"/> <parameter name="scope" value="application"/> </service> </deployment>
ed ho ottenuto il seguente file WSDL dall'URIcodice:C:\projects\StockQuoteService>java org.apache.axis.client.AdminClient -lhttp://l ocalhost:8080/axis/services/AdminService deploy.wsdd Processing file deploy.wsdd <Admin>Done processing</Admin>
http://localhost:8080/axis/services/stock-wss-01?wsdl
3. Poi sono passato alla creazione del Service Client:codice:−<wsdl:definitions targetNamespace="http://localhost:8080/axis/services/stock-wss-01"> −<!-- WSDL created by Apache Axis version: 1.2 Built on May 03, 2005 (02:20:24 EDT) --> −<wsdl:types> −<schema elementFormDefault="qualified" targetNamespace="http://stock.samples"> <element name="symbol" type="xsd:string"/> </schema> −<schema elementFormDefault="qualified" targetNamespace="http://localhost:8080/axis/services/stock-wss-01"> <element name="getQuoteReturn" type="xsd:float"/> </schema> </wsdl:types> −<wsdl:message name="getQuoteResponse"> <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/> </wsdl:message> −<wsdl:message name="getQuoteRequest"> <wsdl:part element="tns1:symbol" name="symbol"/> </wsdl:message> − <wsdl:portType name="StockQuoteService"> − <wsdl:operation name="getQuote" parameterOrder="symbol"> <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/> <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/> </wsdl:operation> </wsdl:portType> − <wsdl:binding name="stock-wss-01SoapBinding" type="impl:StockQuoteService"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> − <wsdl:operation name="getQuote"> <wsdlsoap:operation soapAction=""/> − <wsdl:input name="getQuoteRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> − <wsdl:output name="getQuoteResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> − <wsdl:service name="StockQuoteServiceService"> − <wsdl:port binding="impl:stock-wss-01SoapBinding" name="stock-wss-01"> <wsdlsoap:address location="http://localhost:8080/axis/services/stock-wss-01"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
memorizzando le classi java nel package (e quindi percorso) samples.stock.clientcodice:C:\projects\StockQuoteService>java org.apache.axis.wsdl.WSDL2Java -o . -Nhttp:// localhost:8080/axis/services/stock-wss-01 samples.stock.client http://localhost: 8080/axis/services/stock-wss-01?wsdl
4.Ho scritto il client java StockServiceClient.java che usa le classi generate:
5.ho compilato il package:codice:package samples.stock.client; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; public class StockServiceClient { public StockServiceClient() { } public static void main(String[] args) throws ServiceException, RemoteException { if (args.length == 0) { System.out.println("Usage:\njava StockServiceClient [symbol]"); return; } StockQuoteServiceService locator = new StockQuoteServiceServiceLocator(); StockQuoteService service = locator.getStockWss01(); float quote = service.getQuote(args[0]); System.out.println("stock quote service returned " + args[0] + ": " + quote); } }
6. al momento dell'esecuzione del package:codice:C:\projects\StockQuoteService\samples\stock\client>javac *.java Note: StockQuoteServiceServiceLocator.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
Perchè?codice:C:\projects\StockQuoteService>java samples.stock.client.StockServiceClient IBM Exception in thread "main" AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.io.IOException: Server returned HTTP response code: 502 for U RL: http://services.xmethods.net/axis/getQuote?s=IBM faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}hostname:Martina java.io.IOException: Server returned HTTP response code: 502 for URL: http://ser vices.xmethods.net/axis/getQuote?s=IBM at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder .java:221) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder. java:128) at org.apache.axis.encoding.DeserializationContext.endElement(Deserializ ationContext.java:1087) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source ) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknow n Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent Dispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un known 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$JAXPSAXParser.parse(Unknown Sour ce) at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContext.parse(Deserialization Context.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnders tandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) at org.apache.axis.client.Call.invokeEngine(Call.java:2765) at org.apache.axis.client.Call.invoke(Call.java:2748) at org.apache.axis.client.Call.invoke(Call.java:2424) at org.apache.axis.client.Call.invoke(Call.java:2347) at org.apache.axis.client.Call.invoke(Call.java:1804) at samples.stock.client.StockWss01SoapBindingStub.getQuote(StockWss01Soa pBindingStub.java:106) at samples.stock.client.StockServiceClient.main(StockServiceClient.java: 16)

Rispondi quotando