Torna indietro   Hardware Upgrade Forum > Software > Programmazione

AMD EPYC Venice: dentro Zen 6, i SoC a 256 core e la sfida al costo della memoria
AMD EPYC Venice: dentro Zen 6, i SoC a 256 core e la sfida al costo della memoria
A Las Vegas AMD ha svelato i dettagli architetturali delle CPU EPYC di sesta generazione, note con il nome in codice Venice. Nuovi core Zen 6 e Zen 6c costruiti a 2 nanometri, fino a 256 core per socket, 16 canali di memoria, interfaccia PCI Express 6.0 e un'intera famiglia di proposte che va da Venice SP7 a Verano. Senza dimenticare la memoria, oggi la voce di costo più pesante in un server: AMD risponde con CXL 3.1 e con la tecnologia software MEXT, che porta la memoria flash dentro la gerarchia della DRAM.
HONOR Pad X9 Max recensione, schermo ultra large a meno di 400 euro
HONOR Pad X9 Max recensione, schermo ultra large a meno di 400 euro
HONOR Pad X9 Max mette un pannello IPS da 13 pollici con risoluzione 2,5K e refresh a 120 Hz davanti a una batteria da 10.100 mAh e a quattro altoparlanti. Il listino parte da 399,90 euro, per un progetto molto chiaro e ambizioso: schermo ampio, buon audio e giornate lontano dalla presa, a un prezzo che non pesa sul portafoglio
Lenovo ThinkPad X1 Carbon Gen 14: il business ultraleggero si rinnova dall’interno
Lenovo ThinkPad X1 Carbon Gen 14: il business ultraleggero si rinnova dall’interno
Con la quattordicesima generazione Lenovo ridisegna il suo ThinkPad più iconico attorno al nuovo Space Frame e ai processori Intel Core Ultra Series 3. Resta sotto 1Kg, è molto più semplice da riparare e si rivolge al professionista che lavora in mobilità, con un prezzo da prodotto di vertice.
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 17-05-2008, 08:51   #1
Abdujaparov
Senior Member
 
Iscritto dal: Aug 2004
Città: Palermo
Messaggi: 1079
[JAVA] Web Service con axis2

Salve a tutti, sto iniziando a studiare come creare dei web service con axis2 ma mi sto imbattendo in alcuni problemi.
Ho creato la classe che definisce le operazioni rese disponibili dal web service, la classe è la seguente:
Codice:
package samples.quickstart.service.pojo;

import samples.quickstart.service.pojo.Util.Prodotto;
import java.util.*;

public class StockQuoteService {

	private HashMap map = new HashMap ();
	
	public double getPrice(String symbol){
		
		Double price = (Double) map.get(symbol);
		
		if(price!=null)
			return price.doubleValue();
		
		return 42.0;
	}
	
	public void update(String symbol, double price){
		map.put(symbol, new Double(price));
	}
	
	
	public Prodotto[] getCatalogo(){
		
		Prodotto[] catalogo = new Prodotto[map.size()];
		
		Set chiavi = map.keySet();
		Iterator it = chiavi.iterator();
		

		for(int i=0; i< chiavi.size(); i++){
			String key=(String)it.next();
			catalogo[i]= new Prodotto(key, ((Double) map.get(key)).doubleValue());
		}
		
		return catalogo;
	}
	
}
In particolare l'ultima operazione (getCatalogo) utilizza una classe che ho definito io.
Detto ciò ho generato il pacchetto aar da installare su tomcat (tramite il tool di eclipse "Axis2 service archive") ed ho installato il web service ottenendo questo file wsdl:
Codice:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://pojo.service.quickstart.samples" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://Util.pojo.service.quickstart.samples/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://pojo.service.quickstart.samples">
    <wsdl:documentation>StockQuoteService</wsdl:documentation>
    <wsdl:types>
        <xs:schema xmlns:ax22="http://Util.pojo.service.quickstart.samples/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.service.quickstart.samples">
            <xs:import namespace="http://Util.pojo.service.quickstart.samples/xsd"/>
            <xs:element name="getPrice">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="symbol" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="getPriceResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" type="xs:double"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="getCatalogoResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax22:Prodotto"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="update">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="symbol" nillable="true" type="xs:string"/>
                        <xs:element minOccurs="0" name="price" type="xs:double"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://Util.pojo.service.quickstart.samples/xsd">
            <xs:complexType name="Prodotto">
                <xs:sequence>
                    <xs:element minOccurs="0" name="nome" nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="prezzo" type="xs:double"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="getPriceRequest">
        <wsdl:part name="parameters" element="ns:getPrice"/>
    </wsdl:message>
    <wsdl:message name="getPriceResponse">
        <wsdl:part name="parameters" element="ns:getPriceResponse"/>
    </wsdl:message>
    <wsdl:message name="getCatalogoRequest"/>
    <wsdl:message name="getCatalogoResponse">
        <wsdl:part name="parameters" element="ns:getCatalogoResponse"/>
    </wsdl:message>
    <wsdl:message name="updateRequest">
        <wsdl:part name="parameters" element="ns:update"/>
    </wsdl:message>
    <wsdl:portType name="StockQuoteServicePortType">
        <wsdl:operation name="getPrice">
            <wsdl:input message="ns:getPriceRequest" wsaw:Action="urn:getPrice"/>
            <wsdl:output message="ns:getPriceResponse" wsaw:Action="urn:getPriceResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getCatalogo">
            <wsdl:input message="ns:getCatalogoRequest" wsaw:Action="urn:getCatalogo"/>
            <wsdl:output message="ns:getCatalogoResponse" wsaw:Action="urn:getCatalogoResponse"/>
        </wsdl:operation>
        <wsdl:operation name="update">
            <wsdl:input message="ns:updateRequest" wsaw:Action="urn:update"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="StockQuoteServiceSoap11Binding" type="ns:StockQuoteServicePortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="getPrice">
            <soap:operation soapAction="urn:getPrice" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getCatalogo">
            <soap:operation soapAction="urn:getCatalogo" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="update">
            <soap:operation soapAction="urn:update" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="StockQuoteServiceSoap12Binding" type="ns:StockQuoteServicePortType">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="getPrice">
            <soap12:operation soapAction="urn:getPrice" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getCatalogo">
            <soap12:operation soapAction="urn:getCatalogo" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="update">
            <soap12:operation soapAction="urn:update" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="StockQuoteServiceHttpBinding" type="ns:StockQuoteServicePortType">
        <http:binding verb="POST"/>
        <wsdl:operation name="getPrice">
            <http:operation location="StockQuoteService/getPrice"/>
            <wsdl:input>
                <mime:content type="text/xml" part="getPrice"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="getPrice"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getCatalogo">
            <http:operation location="StockQuoteService/getCatalogo"/>
            <wsdl:input>
                <mime:content type="text/xml" part="getCatalogo"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="getCatalogo"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="update">
            <http:operation location="StockQuoteService/update"/>
            <wsdl:input>
                <mime:content type="text/xml" part="update"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="StockQuoteService">
        <wsdl:port name="StockQuoteServiceHttpSoap11Endpoint" binding="ns:StockQuoteServiceSoap11Binding">
            <soap:address location="http://192.168.1.2:8080/axis2/services/StockQuoteService.StockQuoteServiceHttpSoap11Endpoint"/>
        </wsdl:port>
        <wsdl:port name="StockQuoteServiceHttpSoap12Endpoint" binding="ns:StockQuoteServiceSoap12Binding">
            <soap12:address location="http://192.168.1.2:8080/axis2/services/StockQuoteService.StockQuoteServiceHttpSoap12Endpoint"/>
        </wsdl:port>
        <wsdl:port name="StockQuoteServiceHttpEndpoint" binding="ns:StockQuoteServiceHttpBinding">
            <http:address location="http://192.168.1.2:8080/axis2/services/StockQuoteService.StockQuoteServiceHttpEndpoint"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
A questo punto provo a generare le classi per il client ma ottengo questo errore:
Quote:
angelo@angelo-laptop:~$ wsdl2java.sh -uri http://127.0.0.1:8080/axis2/services...teService?wsdl -p samples.ws.client
Using AXIS2_HOME: /home/angelo/axis2-1.4
Using JAVA_HOME: /usr/lib/jvm/java-6-sun
Retrieving document at 'http://127.0.0.1:8080/axis2/services/StockQuoteService?wsdl'.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.NullPointerException
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: java.lang.NullPointerException
at org.apache.axis2.wsdl.codegen.extension.JavaPrettyPrinterExtension.prettify(JavaPrettyPrinterExtension.java:50)
at org.apache.axis2.wsdl.codegen.extension.JavaPrettyPrinterExtension.prettify(JavaPrettyPrinterExtension.java:51)
at org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.engage(AbstractPrettyPrinterExtension.java:37)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:265)
... 2 more
Nonostante l'errore vengono generate due classi: StockQuoteServiceStub.java e StockQuoteServiceCallbackHandler.java. Se provo ad utilizzare ugualmente quelle classi riesco ad invocare correttamente getPrice, invoco l'operazione update solo che se dopo invoco un getPrice l'update sembra non aver sortito nessun effetto.
Quando invece provo ad invocare getCatalogo come risposta dal web service ottengo null.
Di seguito incollo il client che ho scritto con l'output che mi viene dato:
Codice:
import java.rmi.RemoteException;

import org.apache.axis2.AxisFault;



import test.ws.client.StockQuoteServiceStub;
import test.ws.client.StockQuoteServiceStub.GetPrice;
import test.ws.client.StockQuoteServiceStub.GetPriceResponse;
import test.ws.client.StockQuoteServiceStub.GetCatalogoResponse;
import test.ws.client.StockQuoteServiceStub.Prodotto;
import test.ws.client.StockQuoteServiceStub.Update;

public class X {

	private StockQuoteServiceStub sqss;
	
	public X() throws AxisFault {
		sqss = new StockQuoteServiceStub();
	}

	public static void main(String[] args) throws RemoteException {
		
		X classe = new X();
		
		classe.update("fiat", 50.0);
		classe.update("opel", 72.2);
		classe.update("mercedes", 100);
		
		System.out.println(classe.getPriceW("fiat"));
		System.out.println(classe.getPriceW("mercedes"));
		System.out.println(classe.getPriceW("skoda"));
		System.out.println(classe.getPriceW("opel"));
		
		Prodotto[] ps = classe.getCatalogo();
		
		for(int i=0; i<ps.length; i++)
			System.out.println("Catalogo"+ps[i].getNome()+", "+ps[i].getPrezzo());

	}
	
	public double getPriceW(String nome) throws RemoteException{
		GetPrice parametro = new GetPrice();
		parametro.setSymbol(nome);
		
		GetPriceResponse grp = sqss.getPrice(parametro);
		
		return grp.get_return();
		
	}
	
	public void update(String nome, double prezzo) throws RemoteException{
		Update imp = new Update();
		imp.setSymbol(nome);
		imp.setPrice(prezzo);
		
		sqss.update(imp);
	}
	
	
	public Prodotto[] getCatalogo() throws RemoteException{
		GetCatalogoResponse risposta = sqss.getCatalogo();
		Prodotto[] catalogo = risposta.get_return();
		
		return catalogo;
	}

}
L'output è questo:
Quote:
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
log4j:WARN Please initialize the log4j system properly.
42.0
42.0
42.0
42.0
Exception in thread "main" java.lang.NullPointerException
at X.main(X.java:42)
Cosa completamente sbagliata, dato che 42 mi deve venir tornato solamente se il prodotto non è inserito nella HashMap definita nel web service.

Perchè un comportamento simile? Cosa sbaglio?
Un'ultima cosa, per generare le classi stub ho installato anche il plug-in per eclipse di axis2 (Axis2 code generator), ma questo tool a quanto ho potuto notare non mi funziona mai e non mi da mai nessun file in output mi da un messaggio d'errore:
Quote:
An error occurred while completing process - java.lang.reflect.invocationTargetException
Questo lo ottengo anche se scrivo un altro web service con una sola operazione che fa un'addizione, a questo punto penso sia un problema del plug-in o sbaglio?
Grazie a tutti.
Ciao ciao
Abdujaparov è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


AMD EPYC Venice: dentro Zen 6, i SoC a 256 core e la sfida al costo della memoria AMD EPYC Venice: dentro Zen 6, i SoC a 256 core ...
HONOR Pad X9 Max recensione, schermo ultra large a meno di 400 euro HONOR Pad X9 Max recensione, schermo ultra large...
Lenovo ThinkPad X1 Carbon Gen 14: il business ultraleggero si rinnova dall’interno Lenovo ThinkPad X1 Carbon Gen 14: il business ul...
Jabra Evolve3 85: le cuffie sia per l'intrattenimento che per il lavoro Jabra Evolve3 85: le cuffie sia per l'intratteni...
MSI PRO MAX EDGE AI+, Ryzen AI Max+ 395 e 128 GB per far girare in locale anche i modelli più grandi MSI PRO MAX EDGE AI+, Ryzen AI Max+ 395 e 128 GB...
Starlink Mini 2 è ufficiale: batt...
Tutte le migliori offerte AliExpress con...
Singles' Day AliExpress, prezzi speciali...
Singles' Day AliExpress, console a prezz...
Singles' Day AliExpress, e-bike in offer...
Singles' Day AliExpress, hard disk e SSD...
Singles' Day AliExpress, da mezzanotte n...
iPhone 18e svelato in anticipo: ecco cos...
Rockstar ha un piano preciso per il mult...
Un iPhone Duo da oltre 65 mila dollari: ...
Anthropic: IPO tra 70 e 78 dollari, Goog...
SSHole in OpenSSH è già sfruttata: la CI...
Secure Future Group: il rischio cyber si...
Recensione Anker MagGo Power Bank 2 Pro,...
Salesforce Agentforce Coworker: il colle...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 00:24.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v