如何描述JSR-172(Java ME)消耗的ASP.NET Web服务ENUM

时间:2009-05-20 17:14:57

标签: asp.net web-services java-me

我有.NET Web服务,我正在尝试从Java Mobile手机使用该Web服务。我还将NetBeans开发环境与Web服务工具包一起使用。当我尝试创建代理时,它会在枚举上停滞不前,表明不支持简单类型。有没有办法在WSDL中描述枚举类型,以便工具箱可以理解?

1 个答案:

答案 0 :(得分: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;
    }