Salve, ho un problema con il seguente script che dovrebbe invocare il metodo CalcolaCodiceFiscale di un webservice, elaborare la risposta e visualizzarla:
codice:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script src="lib/jquery/jquery-1.3.2.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function() {
var productServiceUrl = 'http://webservices.dotnethell.it/CodiceFiscale/CalcolaCodiceFiscale'; // Preferably write this out from server side
var soapMessage =
'<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> \
<CalcolaCodiceFiscale xmlns="http://webservices.dotnethell.it/CodiceFiscale"> \
<Nome>nome</Nome> \
<Cognome>cognome</Cognome> \
<ComuneNascita>Comune</ComuneNascita> \
<DataNascita>01/01/1980</DataNascita> \
<Sesso>M</Sesso> \
</CalcolaCodiceFiscale> \
</soap:Body> \
</soap:Envelope>';
$.ajax({
url: productServiceUrl,
type: "POST",
dataType: "xml",
data: soapMessage,
complete: endSaveProduct,
contentType: "text/xml; charset=\"utf-8\""
});
function endSaveProduct(xmlHttpRequest, status)
{
$(xmlHttpRequest.responseXML)
.find('SaveProductResult')
.each(function()
{
var name = $(this).find('Name').text();
})
}
});
</script>
</head>
<body>
<h1>New Web Project Page</h1>
</body>
</html>
In teoria il client dovrebbe inviare al server una richiesta POST includendo all'interno il codice XML. Effettuando un log dei messaggi http scambiati tra client e server, vedo che viene invocato il metodo http OPTIONS anzichè POST ed il server risponde con la lista dei metodi supportati. Dove sbaglio?
Grazie