Sto studiando e allo stesso tempo sto impazzendo....
Dunque, ecco i miei nuovi tentativi.
1. CLASSIC ASP
-------------------------------------------------
Ho preso spunto da questo articolo:
http://www.guru4.net/articoli/asp-soap-client/
Ho quindi creato il file soapclient.asp:
Codice PHP:
<%
function SOAPClient()
{
var m_serviceurl;
var m_servicenamespace = "";
var m_methodname;
var m_parameters = new Array();
this.setServiceUrl = function(val)
{
m_serviceurl = val;
}
this.setServiceNamespace = function(val)
{
m_servicenamespace = val;
}
this.setMethodName = function(val)
{
m_methodname = val;
}
this.addParameter = function(pname, pval)
{
m_parameters[pname] = pval;
}
}
this.call = function()
{
// load WSDL
m_wsdl = Server.CreateObject("Microsoft.XMLDOM") ;
m_wsdl.load(m_serviceurl + "?wsdl");
// build SOAP request
var sXml =
"<?xml version=\"1.0\" ?>" +
"<soap:Envelope " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<" + m_methodname + " xmlns=\"" + m_servicenamespace + "\">";
for(var i in m_parameters)
sXml += "<" + i + ">" + m_parameters[i] + "</" + i + ">";
sXml += "</" + m_methodname + "></soap:Body></soap:Envelope>";
var xmlHTTP = Server.CreateObject("Msxml2.XMLHTTP");
xmlHTTP.Open("Post", m_serviceurl, false);
xmlHTTP.setRequestHeader("SOAPAction", m_servicenamespace + "/" + m_methodname);
xmlHTTP.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHTTP.Send(sXml);
// set raw xml
m_rawxml = xmlHTTP.responseXML.xml + "";
// .NET way - the only way :-)
var nd = xmlHTTP.responseXML.selectSingleNode("//" + m_methodname + "Result");
if(nd == null)
{
if(xmlHTTP.responseXML.selectSingleNode("//faultcode/text()"))
throw new Error(500, xmlHTTP.responseXML.selectSingleNode("//faultcode/text()").nodeValue + " - " + xmlHTTP.responseXML.selectSingleNode("//faultstring/text()").nodeValue);
else
return null;
}
return this.soapresult2object(nd);
}
this.soapresult2object = function(node)
{
return this.node2object(node);
}
this.node2object = function(node)
{
// null node
if(node == null)
return null;
// text node
if(node.nodeType == 3 || node.nodeType == 4)
return this.extractValue(node);
// leaf node
if (node.hasChildNodes() && node.childNodes.length==1 && (node.firstChild.nodeType == 3 || node.firstChild.nodeType == 4))
return this.node2object(node.firstChild);
var isarray = false;
var el = m_wsdl.selectSingleNode("//s:element[@name='" + node.nodeName + "']");
isarray = (el!=null && el.attributes.getNamedItem("type")!=null && (el.attributes.getNamedItem("type").nodeValue + "").toLowerCase().indexOf("arrayof") != -1);
// object node
if(!isarray)
{
var obj = null;
if(node.hasChildNodes())
obj = new Object();
for(var i = 0; i < node.childNodes.length; i++)
{
var p = this.node2object(node.childNodes[i]);
obj[node.childNodes[i].nodeName] = p;
}
return obj;
}
// list node
else
{
// create node ref
var l = new Array();
for(var i = 0; i < node.childNodes.length; i++)
{
var cn = node.childNodes[i];
l[l.length] = this.node2object(cn);
}
return l;
}
return null;
}
this.extractValue = function(node)
{
var value = node.nodeValue;
var el = m_wsdl.selectSingleNode("//s:element[@name='" + node.parentNode.nodeName + "']");
var type = (el != null && el.attributes.getNamedItem("type") != null) ? (el.attributes.getNamedItem("type").nodeValue + "").toLowerCase() : null;
switch(type)
{
default:
case "s:string":
{
return (value != null) ? value + "" : "";
}
case "s:boolean":
{
return value+"" == "true";
}
case "s:int":
case "s:long":
{
return (value != null) ? parseInt(value + "", 10) : 0;
}
case "s:double":
{
return (value != null) ? parseFloat(value + "") : 0;
}
case "s:datetime":
{
if(value == null)
return null;
else
{
value = value + "";
value = value.substring(0, value.lastIndexOf("."));
value = value.replace(/T/gi," ");
value = value.replace(/-/gi,"/");
var d = new Date();
d.setTime(Date.parse(value));
return d;
}
}
}
}
%>
E poi la pagina provasoap.asp, come da indicazioni:
Codice PHP:
<%@ PAGE LANGUAGE="JSCRIPT" %>
<%
// definizione dei dati
var countryCode = "IT";
var vatNumber = "02709820134";
// preparazione della chiamata al Web Service:
var sc = new SOAPClient();
sc.setServiceUrl("http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl");
sc.setServiceNamespace("http://ec.europa.eu/taxation_customs/vies/api/checkVatPort");
sc.setMethodName("checkVat");
sc.addParameter("countryCode", countryCode);
sc.addParameter("vatNumber", vatNumber);
// chiamata e verifica
var u = sc.call();
if(u != "valid") // risposta OK
{
Response.Write("Partita IVA valida");
}
else // risposta KO
{
Response.Write("Partita IVA non valida")
}
%>
A parte il fatto che, nonstante nell'articolo si parli di Classic ASP, l'intestazione <%@ PAGE LANGUAGE="JSCRIPT" %> non mi sembra proprio Classic ma piuttosto ASP.net, infatti ricevo un bell'errore. L'ho quindi cambiata in <%@ LANGUAGE="JSCRIPT" %>.
A questo punto l'errore diventa
Codice PHP:
Errore di run-time di Microsoft JScript error '800a01b6'
Proprietà o metodo non supportati dall'oggetto
/soapclient.asp, riga 32
E la riga in questione è la definizione della funzione CALL
this.call = function()
E qui non so davvero più dove mettere le mani.......
Un aiutino da casa? 
2. JAVASCRIPT / AJAX
-------------------------------------------------
Seguendo le indicazioni dell'articolo correlato:
http://www.guru4.net/articoli/javascript-soap-client/
ho provato anche a realizzare la cosa in Javascript/Ajax.
Vi risparmio ulteriori righe di codice, diciamo che ho seguito la falsa riga degli esempi illustrati alla pagina http://www.guru4.net/articoli/javasc...p-client/demo/ (scrivendo a parte la classe JS come illustrato e poi integrandola nella pagina), ma ricevo sempre un messaggio di errore JAVASCRIPT "Accesso Negato", anche cercando di ricreare in locale la situazione elementare "Hello World!".
Questo da cosa può dipendere?
Grazie in anticipo, baci.
Vado a dormire, sono FUSA! :berto: