PHP Webservices SOAP, struttura file wsdl

w_t

Utente Attivo
3 Set 2007
121
0
16
Salve,
stò affrontando per la prima volta i web services SOAP in PHP, stò cercando di capire le basi e la struttura del file ".wsdl", ho trovato cosi tanti esempi e testi che non so a quale affidarmi, per ogni esempio la struttura cambia, i tag cambiano, insomma è tutto diverso...

Vi chiedo una mano per scegliere una guida dove imparare correttamente come realizzare un web services in PHP e SOAP, escludendo "nusoap e soap rest".

Se ci sono più modi di procedere vorrei imparare quello migliore a livello di sicurezza.

Grazie molte.
 

otto9due

Utente Attivo
22 Feb 2014
590
25
28
Seguo.. è un argomento che mi interessa molto e su cui ho più volte perso la testa cercando di capirci qualcosa..


Saluti G.G.
 

w_t

Utente Attivo
3 Set 2007
121
0
16
Cosa c'è di sbagliato in questo wsdl ?? Funziona ma non credo assolutamente che sia scritto come si deve.

Codice:
<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions 
    name="Library"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="Library"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="Library"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <xsd:documentation></xsd:documentation>

    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="Library">
            <xsd:complexType name="my_value">
                <xsd:sequence>
                    <xsd:element name="my_var" type="xsd:string"></xsd:element>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="MyFunctionRequest">
        <wsdl:part name="_request_" type="xsd:book"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="MyFunctionResponse">
        <wsdl:part name="_response_" type="tns:string"></wsdl:part>
    </wsdl:message>

    <wsdl:portType name="Library">
        <wsdl:operation name="MyFunction_1">
            <wsdl:input message="tns:MyFunctionRequest"/>
            <wsdl:output message="tns:MyFunctionResponse"/>
        </wsdl:operation>
        <wsdl:operation name="MyFunction_2">
            <wsdl:input message="tns:MyFunctionRequest"/>
            <wsdl:output message="tns:MyFunctionResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="Library" type="tns:Library">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="MyFunction_1">
            <soap:operation soapAction="http://127.0.0.1/ws_soap/server.php"/>
            <wsdl:input>
                <soap:body use="literal" namespace="Library"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" namespace="Library"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="MyFunction_2">
            <soap:operation soapAction="http://127.0.0.1/ws_soap/server.php"/>
            <wsdl:input>
                <soap:body use="literal" namespace="Library"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" namespace="Library"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="Library">
        <wsdl:port binding="tns:Library" name="BookLibrary">
            <soap:address location="http://127.0.0.1/ws_soap/server.php"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

Questo è il server:

Codice:
ini_set('soap.wsdl_cache_enabled', 0);

class MyClass
{
    public function MyFunction_1($my_value_1)
    {
        return $my_value_1;
    }
   
    public function MyFunction_2($my_value_2)
    {
        return $my_value_2;
    }
}

$Service = new MyClass();

$server = new SoapServer("ws.wsdl");
$server->setObject($Service);
$server->handle();

Questo è il client:

Codice:
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', 0);

$wsdl = 'http://127.0.0.1/ws_soap/server.php/method?WSDL';

$options = array(
                'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
                'style'=>SOAP_RPC,
                'use'=>SOAP_ENCODED,
                'soap_version'=>SOAP_1_1,
                'cache_wsdl'=>WSDL_CACHE_NONE,
                'connection_timeout'=>15,
                'trace'=>true,
                'encoding'=>'UTF-8',
                'exceptions'=>true,
                );

$objClient = new SoapClient($wsdl, $options);

try
{
    if(isset($objClient))
    {
        $resp1 = $objClient->MyFunction_1("Ciao ");
        $resp2 = $objClient->MyFunction_2(" sono Mario");
       
        echo $resp1.$resp2;
    }
}
catch(SoapFault $ex)
{
    echo var_dump($ex);
}
 

Dell Support

Nuovo Utente
30 Mag 2018
1
0
0
Codice:
<? xml version = "1.0" encoding = "UTF-8"?>

<Wsdl: definitions
    name = "Library"
    xmlns: xsd = "http://www.w3.org/2001/XMLSchema"
    targetNamespace = "Library"
    xmlns: soap = "http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns: tns = "Library"
    xmlns: wsdl = "http://schemas.xmlsoap.org/wsdl/">

    <Xsd: documentation> </ xsd: documentation>

    <Wsdl: types>
        <xsd: schema xmlns: xsd = "http://www.w3.org/2001/XMLSchema" targetNamespace = "Library">
            <xsd: complexType name = "my_value">
                <Xsd: sequence>
                    <xsd: element name = "my_var" type = "xsd: string"> </ xsd: element>
                </ Xsd: sequence>
            </ Xsd: complexType>
        </ Xsd: schema>
    </ Wsdl: types>

    <wsdl: message name = "MyFunctionRequest">
        <wsdl: part name = "_ request_" type = "xsd: book"> </ wsdl: part>
    </ Wsdl: message>
    <wsdl: message name = "MyFunctionResponse">
        <wsdl: part name = "_ response_" type = "tns: string"> </ wsdl: part>
    </ Wsdl: message>

    <wsdl: portType name = "Library">
        <wsdl: operation name = "MyFunction_1">
            <wsdl: input message = "tns: MyFunctionRequest" />
            <wsdl: output message = "tns: MyFunctionResponse" />
        </ Wsdl: operation>
        <wsdl: operation name = "MyFunction_2">
            <wsdl: input message = "tns: MyFunctionRequest" />
            <wsdl: output message = "tns: MyFunctionResponse" />
        </ Wsdl: operation>
    </ Wsdl: portType>

    <wsdl: binding name = "Library" type = "tns: Library">
        <soap: binding style = "rpc" transport = "http://schemas.xmlsoap.org/soap/http" />
        <wsdl: operation name = "MyFunction_1">
            <soap: operation soapAction = "http://127.0.0.1/ws_soap/server.php" />
            <Wsdl: input>
                <soap: body use = "literal" namespace = "Library" />
            </ Wsdl: input>
            <Wsdl: output>
                <soap: body use = "literal" namespace = "Library" />
            </ Wsdl: output>
        </ Wsdl: operation>
        <wsdl: operation name = "MyFunction_2">
            <soap: operation soapAction = "http://127.0.0.1/ws_soap/server.php" />
            <Wsdl: input>
                <soap: body use = "literal" namespace = "Library" />
            </ Wsdl: input>
            <Wsdl: output>
                <soap: body use = "literal" namespace = "Library" />
            </ Wsdl: output>
        </ Wsdl: operation>
    </ Wsdl: binding>

    <wsdl: service name = "Library">
        <wsdl: port binding = "tns: Library" name = "BookLibrary">
            <soap: address location = "http://127.0.0.1/ws_soap/server.php" />
        </ Wsdl: port>
    </ Wsdl: service>

</ Wsdl: definitions>
[/ Code]

This is the server:

[Code]
ini_set ('soap.wsdl_cache_enabled', 0);

class MyClass
{
    public function MyFunction_1 ($ my_value_1)
    {
        return $ my_value_1;
    }
 
    public function MyFunction_2 ($ my_value_2)
    {
        return $ my_value_2;
    }
}

$ Service = new MyClass ();

$ server = new SoapServer ("ws.wsdl");
$ Server-> setObject ($ service);
$ Server-> handle ();
[/ Code]

This is the client:

[Code]
ini_set ('soap.wsdl_cache_enabled', 0);
ini_set ('soap.wsdl_cache_ttl', 0);

$ wsdl = 'http://127.0.0.1/ws_soap/server.php/method?WSDL';

$ options = array (
                'Uri' => 'http://schemas.xmlsoap.org/soap/envelope/',
                'Style' => SOAP_RPC,
                'Use' => SOAP_ENCODED,
                'Soap_version' => SOAP_1_1,
                'Cache_wsdl' => WSDL_CACHE_NONE,
                'Connection_timeout' => 15,
                'Trace' => true,
                'Encoding' => 'UTF-8',
                'Exceptions' => true,
                );

$ objClient = new SoapClient ($ wsdl, $ options);

try
{
    if (isset ($ objClient))
    {
        $ resp1 = $ objClient-> MyFunction_1 ("Hello");
        $ resp2 = $ objClient-> MyFunction_2 ("sono Mario");
   
        echo $ resp1. $ resp2;
    }
}
catch (SoapFault $ ex)
{
    echo var_dump ($ ex);
}
[/ Code] [/ QUOTE]
 Read this comment This is very useful, I also have a suggestion for those people who want to face the problem or do not be able to do this. simply take a help of https://dellsupports.org/ to solve the problem properly. If anyone faces any problem related to Dell they can also help.
 
Ultima modifica:

LinuxOhYeah

Utente Attivo
26 Nov 2016
186
7
18
le basi e la struttura del file ".wsdl"
Potresti iniziare con WSDL: scopriamo cos'è il Web Services Description Language uno degli articoli che trovi su https://www.mrw.it/xml/articoli/

Trovi anche: SOAP: cos'è e come funziona

Buona lettura :)

C'è anche per Android: Far dialogare la nostra app con un web service tramite WSDL e SOAP

e https://www.mrw.it/php/usare-curl-php-interagire-risorse-remote_12050.html -> Inviare dei dati nel formato JSON ad un web-service remoto
 
Ultima modifica:
Discussioni simili
Autore Titolo Forum Risposte Data
F Cerco Hosting con VECCHIE versioni di php Hosting 0
Cosina Captcha php PHP 1
S passare un valore da un form a un file .php con metodo post PHP 4
N php msyql PHP 6
N php problemi a visualizzare video PHP 3
A menu a tendina php PHP 1
D protezione cartelle: blocco visualizzazione/scaricamento contenuto, ma abilitazione utilizzo dati da parte di file .php presenti sul sito Web Server 1
F Php date_diff PHP 1
K [PHP] Aggiungere caratteri ad una stringa in base alla lunghezza della stessa PHP 2
C Wp-admin a file php WordPress 5
Lino80 [Retribuito] Cerco programmatore php per modifica/inserimento funzione/valori da un plugin importer wordpress Offerte e Richieste di Lavoro e/o Collaborazione 0
csi Inviare file jpg in locale alla stampante con php PHP 0
M Passaggio variabili array php su un tasto jq PHP 3
E Php aggiornamento tabella PHP 9
G phpmailer e php 8.1 con estensione mysqli PHP 6
M Invio dati database via email php PHP 0
K [php] Problema con inner join PHP 4
K [php]form invio dati PHP 0
P Codifica caratteri speciali mysql php PHP 0
K [PHP] Problema con variabili concatenate. PHP 1
E Stampante termica escpos-php PHP 6
JeiMax Modifica codice php personalizzato PHP 2
G Come modificare un pdf in php PHP 1
U Link a doppio file PHP PHP 0
E PHP & jQuery PHP 8
N Passare array da php a javascript PHP 5
F Applicazione PHP/MySQL per prenotazioni: limitare il numero massimo di posti prenotabili PHP 20
L tipo boolean non funzionante su mariadb (mysql). E codice php 7.4. PHP 0
U PHP creare un file excel dopo ricerca nel DB PHP 0
M PHP/MySQL - Estrarre valori min e max di ogni gruppo PHP 5
F Php e fatturazione elettronica PHP 0
P lanciare script asp (o php) da jquery Javascript 1
Couting95 inserire dati da un file di testo in una tabella in php PHP 1
P Data scraping in PHP non funziona PHP 4
C Calcoli matematici in php PHP 5
F Scrivere dei dati in word con php PHP 0
D PHP leggere cartella di Windows PHP 1
I dominio aruba versione php server linux Domini 3
G Colorare menu select attraverso ricerca php PHP 0
L PHP motore di ricerca nel sito PHP 1
S PHP e Mysqli PHP 0
Y Stampare da php su un foglio A6 attraverso una stampante esterna PHP 1
M Visulizzare immagine con php PHP 8
G [PHP] Creare script di prenotazione con controllo disponibilità. PHP 7
G leggere file txt e stampare con php il contenuto a video PHP 7
F Ricreare struttura php+mysql su Xampp Apache 0
Z PHP.INI - STMP per invio email con PHP Server Dedicati e VPS 0
M Array associativi php su 2 campi mysql PHP 10
G Invio form con PHP PHP 3
T fatture con voci fattura in php PHP 0

Discussioni simili