SOAP ws

Ciao a tutti, devo interrogare un servizio SOAP, nello specifico il servizio InviaSMS di Macnil Zucchetti (trovate il WDSL con alcune info qui: http://www.smsmacnil.it/smsgw/SMS.asmx)

se lancio il ws da un tool online di verifica soap, funziona correttamente, ricevo l’sms

questa la request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://smsmacnil.it/smsgw/">
  <SOAP-ENV:Body>
    <ns1:InviaSMS>
      <ns1:CodiceCliente>CLIENTE_TEST</ns1:CodiceCliente>
      <ns1:Password>miapassword</ns1:Password>
      <ns1:IdRichiesta>0</ns1:IdRichiesta>
      <ns1:Mittente>fivestars</ns1:Mittente>
      <ns1:Testo>prova invio</ns1:Testo>
      <ns1:Destinatari>3491234567</ns1:Destinatari>
      <ns1:Notifica>true</ns1:Notifica>
    </ns1:InviaSMS>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

e questo il result:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <InviaSMSResponse
            xmlns="http://smsmacnil.it/smsgw/">
            <InviaSMSResult>
                <error_code>0</error_code>
                <id_Richiesta>0</id_Richiesta>
                <EsitiInviaSMSElements>
                    <EsitoInviaSMSElement>
                        <Id_SMS>80773241</Id_SMS>
                        <Destinatario>3492928501</Destinatario>
                        <Residuo>49</Residuo>
                    </EsitoInviaSMSElement>
                </EsitiInviaSMSElements>
            </InviaSMSResult>
        </InviaSMSResponse>
    </soap:Body>
</soap:Envelope>

se lo faccio da xojo ottengo un errore Exception as SOAP Exception,
Error number 0
Message Incorrect Parameters
Reason Incorrect Parameters

questo il mio codice dietro ad un evento action di un pulsante (i parametri sono identici al tool online…=

Dim sm As SOAPMethod
Dim sr As SOAPResult

Dim Address as String = "http://www.smsmacnil.com/smsgw/SMS.asmx?WSDL"

sm = New SOAPMethod(Address)

sm.Parameter("CodiceCliente") = "CLIENTE_TEST"
sm.Parameter("Password") = "miapassword"
sm.Parameter("IdRichiesta") = "0"
sm.Parameter("Mittente") = "fivestars"
sm.Parameter("Testo") = "prova invio"
sm.Parameter("Destinatari") = "3491234567"

sr = sm.Invoke("InviaSMS")

l’errore ovviamente me lo da alla riga sr = sm.Invoke(“InviaSMS”)

ho un dubbio sul parametro sm.Parameter(“IdRichiesta”) = “0” che deve essere int.

ho forse dimenticato io qualcosa? scusate ma il primo SOAP che chiamo :frowning:

Dal WSDL sembrerebbe che il parametro “IdRichiesta” debba essere int, ma tu passi string.
prova con

...
sm.Parameter("IdRichiesta") = 0
...

trovato, mancava il parametro notifica!

bene! step 2, altro ws: ho di ritorno una list con gli sms ricevuti, come la processo, magari popolando una listbox?

Dim sm As SOAPMethod
Dim sr As SOAPResult

Dim Address as String = "http://www.smsmacnil.com/smsgw/SMS.asmx?WSDL"

sm = New SOAPMethod(Address)

sm.Parameter("CodiceCliente") = "CLIENTE_TEST"
sm.Parameter("Password") = "miapassword"
sm.Parameter("IdRichiesta") = 0
sm.Parameter("DaDataV") = "01/01/2018 00:00"

sr = sm.Invoke("SmsRicevuti")

If sr.Error Then
  Msgbox(sr.ErrorMessage)
end if

questo il result:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <SmsRicevutiResponse
            xmlns="http://smsmacnil.it/smsgw/">
            <SmsRicevutiResult>
                <error_code>0</error_code>
                <id_Richiesta>0</id_Richiesta>
                <SmsRicElements>
                    <SmsRicElement>
                        <Data>01/04/2018 00:00:14</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018 12:00AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 00:06:53</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018 12:06AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 00:30:58</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018 12:30AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:08:15</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:08AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:11:04</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:11AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:31</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:37</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:37</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:37</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:39</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:39</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:46</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:46</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:50</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:51</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:51</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:51</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:51</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                    <SmsRicElement>
                        <Data>01/04/2018 01:12:51</Data>
                        <NumeroCellulare>+3933512345</NumeroCellulare>
                        <Testo>SMS test ricezione NCSSRL apr  1 2018  1:12AM</Testo>
                    </SmsRicElement>
                 </SmsRicElements>
            </SmsRicevutiResult>
        </SmsRicevutiResponse>
    </soap:Body>
</soap:Envelope>