Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    WebServiceProxyFactory is not defined

    Ciao,
    sto sviluppando un client che deve connettersi ad un web service e poichè sono su domini diversi nasce il problema del CROSS DOMAIN. Per questo ho trovato uno script lato client che mi dovrebbe creare un proxy e collegarsi al web service. Riporto il codice dello script:

    codice:
      var gProxy = null;
    
      function Translate(aLangToFrom){
        if (!gProxy) {
         var listener = {
    
          // gets called once the proxy has been instantiated
          onLoad: function (aProxy)
          {
            gProxy = aProxy;
            gProxy.setListener(listener);
            requestTranslation(aLangToFrom);
          },
    
          // gets called if an error occurs
          onError: function (aError)
          {
            alert("An error has occured: " + aError);
          },
    
          // callback function is hardcoded to {methodname}Callback
          ConvertiInLettereCallback  : function (aResult)
          {
            document.getElementById("results").innerHTML = aResult;
          }
        };
    
        createProxy(listener);
      } else {
        requestTranslation(aLangToFrom);
      }
    }
    
    function createProxy(aCreationListener){
      try {
        var factory = new WebServiceProxyFactory();
        factory.createProxyAsync("http://www.studiobasso.com/ws/cifrelettere.asmx?wsdl", "CifreLettereSoap", "", true, aCreationListener);
      } catch (ex) {
        alert("Failed creating the proxy: "+ ex);
      }
    }
    
    function requestTranslation(aLangToFrom){
      if (gProxy) {
        gProxy.ConvertiInLettere(aLangToFrom);
      } else {
        alert("Error: Proxy hasn't been set up correctly!");
      }
    }
    
     Translate('150');

    In Mozilla Firefox, eseguendo la pagina ottengo il seguente errore:

    Failed creating the proxy: ReferenceError: WebServiceProxyFactory is not defined


    Qualcuno mi sa dire come potrei risolvere il problema o se questa soluzione per il proxy è conveniente?

  2. #2
    Ciao,
    il proxy si fanno lato server con php ad esempio.
    Altra possibilita se il web server è predisposto
    http://bob.pythonmac.org/archives/20...te-json-jsonp/


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    sono d'accordo sul fatto che il proxy va sul lato server, ma ho tentato questa strada perchè eseguendo dei proxy in jsp o php il metodo post mi veniva convertito in get e quindi perdeva i dati che sarebbero dovuti arrivare al web service. Mi sai dire perchè succedeva questo?

  4. #4
    Originariamente inviato da sparossella
    sono d'accordo sul fatto che il proxy va sul lato server, ma ho tentato questa strada perchè eseguendo dei proxy in jsp o php il metodo post mi veniva convertito in get e quindi perdeva i dati che sarebbero dovuti arrivare al web service. Mi sai dire perchè succedeva questo?
    Se non fai qc esempio la vedo dura


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Originariamente inviato da sparossella
    eseguendo dei proxy in jsp o php il metodo post mi veniva convertito in get
    Il problema e' lato server.

    ciao
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  6. #6
    Originariamente inviato da br1
    Il problema e' lato server.

    ciao

    si...quindi? Questo è il codice Jsp che ho provato lato server:

    codice:
    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"
    import="java.io.BufferedReader,
    java.io.InputStreamReader,
    java.io.IOException,
    java.io.InputStream,
    java.net.MalformedURLException,
    java.net.URL,
    javax.servlet.*,
    java.net.URLConnection"
    %>
    <%!
    private String contentURL;
    public static final String CONTENT_URL_NAME = "contentURL";
    %>
    <%
    // get the url through the request:
    if (contentURL == null) {
    contentURL = (String)request.getAttribute(CONTENT_URL_NAME);
    if (contentURL == null)
    contentURL = (String)request.getParameter(CONTENT_URL_NAME);
    }
    if (contentURL == null)
    
    throw new ServletException("A content URL must be provided, as a " + CONTENT_URL_NAME + " request attribute or request parameter.");
    URL url = null;
    try {
    // get a connection to the content:
    
    System.out.println(contentURL);
    
    url = new URL(contentURL);
    URLConnection urlConn = url.openConnection();
    // show the client the content type:
    String contentType = urlConn.getContentType();
    response.setContentType(contentType);
    // get the input stream
    InputStream in = urlConn.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    char[] buffer = new char[1024];
    String contentString = "";
    String tmp = br.readLine();
    do
    {
    contentString += tmp + "\n";
    tmp = br.readLine();
    }
    while (tmp != null);
    out.flush();
    out.close();
    }
    catch (MalformedURLException me) {
    // on new URL:
    throw new ServletException("URL: '" + contentURL + "' is malformed.");
    }
    catch (IOException ioe) {
    // on opne connection:
    throw new ServletException("Exception while opening '" + contentURL + "': " + ioe.getMessage());
    }
    catch (Exception e) {
    // on reading input:
    throw new ServletException("Exception during proxy request: " + e.getMessage());
    }
    %>
    lo script fa una GET invece a me serve che faccia una POST...come potrei fare? avete qualche script di un proxy che faccia una POST?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.