使用JAVA调用.NET写的WEB SERVICES(急!) 调用Web Service的时候,你接收到的是通过HTTP信道传过来的一个XML格式的字符序列,自己用XML解析器可以把它解析成一份XML文档(当然还有别的更方便的工具),哪里会有什么对象类型的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to Schlemiel: 但是如何使用java调用呢?例子有吗? 完全没问题,记得和另一公司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你也可以自己解析 完全没问题,记得和另一公司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你也可以自己解析 java数组排序 有关JS中数组变量的问题 救命!!求助utf-8转GBK怎么转! 关于重写hashCode()方法 spring +hibernate整合 怎样实现qq迷你屋的物品的添加,和拖拉拽的效果?? struts中request不能得到已保存的对象 大连想找一份不要求日语的JAVA工作! j2ee开发 dom4j不能处理中文的xml文件????? 将XML转化为HTML的一个问题 使用JDOM 输出xml文档的一个问题
但是如何使用java调用呢?例子有吗?
用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你也可以自己解析
用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你也可以自己解析