2012-09-10 12 views
1

我想在JavaScript中使用XML SOAP Web服务来创建Firefox Addon,但我想要使用的Web服务是在安全的https连接下。如何通过安全的https连接在JavaScript中使用基于soap xml的web服务?

https://cuotas.uci.cu:443/servicios/v1/InetCuotasWS.wsdl

我下载不使用安全连接工作soapclient.js库。我怎么解决这个问题?有没有现有的有用的JS库?

编辑: 这是显示在链接

<!-- WSDL file generated by Zend Studio. --><definitions name="InetCuotasWS" targetNamespace="urn:InetCuotasWS"> 
<types><xsd:schema targetNamespace="urn:InetCuotasWS"> 
<xsd:complexType name="Usuario"><xsd:all> 
<xsd:element name="cuota" type="xsd:float"/><xsd:element name="cuota_usada" type="xsd:anyType"/> 
<xsd:element name="nivel_navegacion" type="xsd:string"/> 
<xsd:element name="usuario" type="xsd:string"/> 
</xsd:all></xsd:complexType></xsd:schema></types> 
<message name="ObtenerCuota"><part name="usuario" type="xsd:string"/><part name="clave" type="xsd:string"/> 
<part name="dominio" type="xsd:string"/></message> 
<message name="ObtenerCuotaResponse"><part name="ObtenerCuotaReturn" type="typens:Usuario"/></message><portType name="InetCuotasWSPortType"> 
<operation name="ObtenerCuota"><documentation> 
      Obtener el estado de la cuota de un usuario dado su usuario y clave. 
     </documentation> 
<input message="typens:ObtenerCuota"/> 
<output message="typens:ObtenerCuotaResponse"/></operation></portType><binding name="InetCuotasWSBinding" type="typens:InetCuotasWSPortType"> 
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
<operation name="ObtenerCuota"><soap:operation soapAction="urn:InetCuotasWSAction"/><input><soap:body namespace="urn:InetCuotasWS" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
</input><output><soap:body namespace="urn:InetCuotasWS" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
</output></operation></binding><service name="InetCuotasWSService"><port name="InetCuotasWSPort" binding="typens:InetCuotasWSBinding"><soap:address location="https://cuotas.uci.cu/servicios/v1/InetCuotasWS.php"/> 
</port></service></definitions> 

编辑 我用了SoapUI如你所说,这是URI https://cuotas.uci.cu/servicios/v1/InetCuotasWS.php?wsdl 和的SOAPMessage是

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:InetCuotasWS"> 
<soapenv:Header/><soapenv:Body> 
<urn:ObtenerCuota soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
<usuario xsi:type="xsd:string">dogcalas</usuario> 
<clave xsi:type="xsd:string">.*Pepe</clave> 
<dominio xsi:type="xsd:string">uci</dominio> 
</urn:ObtenerCuota></soapenv:Body></soapenv:Envelope>  

当我在Firefox中发送soap消息时,警报('ERROR ')显示,Firefox的firebug插件显示此消息。

错误德LECTURA XML:无SE encuentra ELEMENTOUbicación: MOZ-nullprincipal:{fc98c066-ae21-4b57-b743-83e9519342c7}NÚMERO德 拉利内阿1,columna 1:

即使使用另一项服务,Firefox总是显示相同的消息。 只有当我使用Internet Explorer 10,发送消息,但服务器响应isn't我的期望:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode> 
<faultstring>SoapClient::SoapClient() [&lt;a href='soapclient.soapclient'&gt;soapclient.soapclient&lt;/a&gt;]: 'location' and 'uri' options are required in nonWSDL mode</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> 

在IE中,如果我使用其他的服务,脚本工作。

+1

所有原始信息,除非该服务器支持[CORS(http://en.wikipedia.org/wiki/Cross-origin_resource_sharing),你可能会被卡住与[CROSS-DOMAIN](http://stackoverflow.com/questions/2882522/crossdomain-error)错误。 ** P.S **链接无处可去。 – balexandre

+0

ups,链接只是为我的大学 – Abs

+0

,那么你将有一个很大的问题,做这个插件...;) – balexandre

回答

0

如果你不关心跨域,那么你可以试试这个......我将使用jQuery,因为它更简单,如果你必须转换成你自己的语法,我永远不会做了Mozilla插件。

注:你需要得到正确的URL呼叫,并正确SOAP消息

对于这一点,我建议你安装SoapUI并连接到服务,您将得到需要在JavaScript的发送和接收信息

var webServiceURL = 'https://cuotas.uci.cu:443/servicios/v1/InetCuotasWS?op=ObtenerCuota'; 
var soapMessage = '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><ObtenerCuota xmlns="http://tempuri.org/" /></soap12:Body></soap12:Envelope>'; 

function CallService() 
{ 
    $.ajax({ 
     url: webServiceURL, 
     type: "POST", 
     dataType: "xml", 
     data: soapMessage, 
     contentType: "text/xml; charset=\"utf-8\"", 
     success: OnSuccess, 
     error: OnError 
    }); 

    return false; 
} 

function OnSuccess(data, status) 
{ 
    alert(data.d); 
} 

function OnError(request, status, error) 
{ 
    alert('error'); 
} 

$(function() { 
    jQuery.support.cors = true; 
}); 
相关问题