2009-05-20 8 views
0

J'ai le service Web .NET et j'essaie d'utiliser ce service Web à partir d'un téléphone Java Mobile. J'utilise également l'environnement de développement NetBeans avec le kit d'outils de service Web. Lorsque j'essaie de créer les proxies, cela ne tient pas compte des énumérations indiquant que les types simples ne sont pas pris en charge. Existe-t-il un moyen de décrire le type d'énumération dans le WSDL afin qu'il soit compréhensible pour le toolkit?Comment décrire un service Web ASP.NET ENUM pour JSR-172 (Java ME) Consommation

Répondre

0
// send a POST request to web server 
    public String sendPostRequest(String urlstring, String requeststring) 
    { 
      HttpConnection hc = null; 
      DataInputStream dis = null; 
      DataOutputStream dos = null; 

      String message = ""; 

      // specifying the query string 
      String requeststring = "request=gettimestamp"; 
      try 
      { 
        // openning up http connection with the web server 
        // for both read and write access 
        hc = (HttpConnection) Connector.open(urlstring, Connector.READ_WRITE); 

        // setting the request method to POST 
        hc.setRequestMethod(HttpConnection.POST); 
        hc.setRequestProperty("User-Agent","Profile/MIDP-2.0 Confirguration/CLDC-1.0"); 
        hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 


        // obtaining output stream for sending query string 
        dos = hc.openDataOutputStream(); 
        byte[] request_body = requeststring.getBytes(); 

        // sending query string to web server 
        for (int i = 0; i < request_body.length; i++) 
        { 
          dos.writeByte(request_body[i]); 
        } 
        // flush outdos.flush(); 

        // obtaining input stream for receiving HTTP response 
        dis = new DataInputStream(hc.openInputStream()); 

        // reading the response from web server character by character 
        int ch; 
        while ((ch = dis.read()) != -1) 
        { 
          message = message + (char) ch; 
        } 

      } 
      catch (IOException ioe){ 
        message = "ERROR"; 
      } 
      finally{ 
        // freeing up i/o streams and http connection 
        try{ 
          if (hc != null) 
            hc.close(); 
        } 
        catch (IOException ignored){} 
        try{ 
          if (dis != null) 
            dis.close(); 
        } 
        catch (IOException ignored){} 
        try{ 
          if (dos != null) 
            dos.close(); 
        } 
        catch (IOException ignored){} 
      } 
      return message; 
    } 
Questions connexes