调用Web Service的时候,你接收到的是通过HTTP信道传过来的一个XML格式的字符序列,自己用XML解析器可以把它解析成一份XML文档(当然还有别的更方便的工具),哪里会有什么对象类型的?

解决方案 »

  1.   

    to Schlemiel:
       但是如何使用java调用呢?例子有吗?
      

  2.   

    完全没问题,记得和另一公司webservice with C#合作时
    用java调用是这样写的
    RecDocument是自己封闭的Document你就想成Dom吧    /**
         * 公共对外的接口
         * @param doc
         * @param endpoint
         * @param soapAction
         * @return 是否发送成功
         */
        public static boolean recDocumentWS(RecDocument doc, String endpoint, String soapAction) {
            boolean ret = false;
            SOAPMessage msg = new SOAPMessage();
            Document d = SOAPUtils.getDocument(doc);
            msg.setDocument(d);        msg.setSoapAction(soapAction);
            try {            SOAPMessage retmsg = HTTPUtils.post(new URL(endpoint), msg);
                Document respDoc = retmsg.getDoc();
                Element payload = null;
                if (respDoc != null) {
                    payload = respDoc.getDocumentElement();
                    String ret2 = payload.getElementsByTagName("RecDocumentResult").item(0).getFirstChild().getNodeValue();
                    if (ret2.equalsIgnoreCase("true")) ret = true;
                } else {
                    throw new SOAPException(HttpConstants.FAULT_CODE_CLIENT,
                            "Parsing error for the return content:" + retmsg.getStringMsg());
                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (SOAPException e) {
                e.printStackTrace();
            } catch (SAXException e) {
                e.printStackTrace();
            }
            return ret;
        }实际写时就那样
          Call call = new Call();
          Parameter param = new Parameter("caller", caller.getClass(), caller, 
                                          Constants.NS_URI_SOAP_ENC);      call.setTargetObjectURI(uri);
          call.setMethodName(remoteMethod);
          call.setParams(new Vector(Arrays.asList(new Parameter[] {
            param
          })));      Response resp = call.invoke(new URL(url), "");而且如果你用其它方式如URL返回也是个XML DOM你也可以自己解析
      

  3.   

    完全没问题,记得和另一公司webservice with C#合作时
    用java调用是这样写的
    RecDocument是自己封闭的Document你就想成Dom吧    /**
         * 公共对外的接口
         * @param doc
         * @param endpoint
         * @param soapAction
         * @return 是否发送成功
         */
        public static boolean recDocumentWS(RecDocument doc, String endpoint, String soapAction) {
            boolean ret = false;
            SOAPMessage msg = new SOAPMessage();
            Document d = SOAPUtils.getDocument(doc);
            msg.setDocument(d);        msg.setSoapAction(soapAction);
            try {            SOAPMessage retmsg = HTTPUtils.post(new URL(endpoint), msg);
                Document respDoc = retmsg.getDoc();
                Element payload = null;
                if (respDoc != null) {
                    payload = respDoc.getDocumentElement();
                    String ret2 = payload.getElementsByTagName("RecDocumentResult").item(0).getFirstChild().getNodeValue();
                    if (ret2.equalsIgnoreCase("true")) ret = true;
                } else {
                    throw new SOAPException(HttpConstants.FAULT_CODE_CLIENT,
                            "Parsing error for the return content:" + retmsg.getStringMsg());
                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (SOAPException e) {
                e.printStackTrace();
            } catch (SAXException e) {
                e.printStackTrace();
            }
            return ret;
        }实际写时就那样
          Call call = new Call();
          Parameter param = new Parameter("caller", caller.getClass(), caller, 
                                          Constants.NS_URI_SOAP_ENC);      call.setTargetObjectURI(uri);
          call.setMethodName(remoteMethod);
          call.setParams(new Vector(Arrays.asList(new Parameter[] {
            param
          })));      Response resp = call.invoke(new URL(url), "");而且如果你用其它方式如URL返回也是个XML DOM你也可以自己解析