是不是返回值设置String,包含XML,
然后客户端自己解析?
然后客户端自己解析?
解决方案 »
- java中,比如说我想在页面得到一个类list,一般会写getset方法,如果我直接把得到的值卸载get方法里好吗?
- usebean标签undefined type 未定义类型
- tomcat5.5环境变量的配置
- 利用JXL导出为Excel,怎么操作输入流
- jsp 上传文件 系统找不到指定文件(急急急...)
- 有人用axis吗?帮忙哈!!
- 想把SQL语句从JAVA代码里剥离,该怎么处理?
- 字符串的变量的内容是类名,如何调用类的方法
- 欢迎测试工作流程自定义
- 我想配置一个普通文件 这个文件每行有两个数据 然后读取这个文件 把数据弄到hashmap里面 怎么弄呢
- 我在a机器的weblogic上配置了一个ejb,在b机器的weblogic上的servlet中能不能调用a的ejb啊
- struts:提交到某个action后,如果点刷新还可一再提交一次,请问如何避免啊(我已经return mapping.findForward("...")了)
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/behaviors/library/webservice/default.asp
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp
http://www.codeguru.com/csharp/csharp/cs_webservices/tutorials/article.php/c7781__1/
使用SOAP TOOL KIT
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=D4490E52-5F6E-4127-9DC7-88B7C8F83B74
使用MSXML
http://www.microsoft.com/downloads/details.aspx?FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&DisplayLang=en
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/2334bff1-d389-4c62-a6c0-bc8517aa4cf1.asp
使用COM
使用COM Interop 技术
客户端需要返回自定义类型的数据,一直无法正常调用成功,如果返回非自定义的数据则可以调用成功在Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");时总是出错
怎么解决呢?详细代码如下:
服务器端
//////////////////////////////////////////////////
//DataServices.jws
import sms.*;
import java.util.HashMap;public class DataServices {
public Data buildData(String address,String aouthor ){
Data data=new Data();
data.setAddress(address) ;
data.setAouthor(aouthor) ;
HashMap map=new HashMap();
map.put("key1","value1") ;
map.put("key2","value2") ;
map.put("key3","value3") ;
data.setMap(map);
return data;
}
}//Data.java
package sms;
import java.util.HashMap;
public class Data {
private String author=null;
private String address=null;
private HashMap hmap=null;
public Data() {
}
public String getAddress(){
return address;
}
public void setAddress(String address){
this.address=address;
}
public String getAouthor(){
return author;
}
public void setAouthor(String author){
this.author=author;
}
public HashMap getHMap(){
return hmap;
}
public void setHMap(HashMap map){
this.hmap=map;
}
}//客户端代码
//////////////////////////////////////////////////////
void CTestSoapClientDlg::CallService()
{
try{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector; // Connect to the service
if(FAILED(Connector.CreateInstance(__uuidof(HttpConnector30)))){
AfxMessageBox("Create HTTP Connector Failed!");
return;
}
Connector->Property["EndPointURL"] = "http://127.0.0.1:8000/axis/DataServices.jws?wsdl";
Connector->Connect(); // Begin message
Connector->Property["SoapAction"] = "";
Connector->BeginMessage(); // Create the SoapSerializer
if(FAILED(Serializer.CreateInstance(__uuidof(SoapSerializer30)))){
AfxMessageBox("Create SOAP Serializer Failed!");
return;
} // Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream)); // Build the SOAP Message
Serializer->StartEnvelope("","","");
Serializer->StartBody(""); Serializer->StartElement("hello","http://DefaultNamespace","",""); Serializer->StartElement("address","","","");
Serializer->WriteString("test");
Serializer->EndElement(); Serializer->StartElement("aouthor","","","");
Serializer->WriteString("qinws");
Serializer->EndElement(); Serializer->EndElement();
char buf[4096]; Serializer->EndBody();
Serializer->EndEnvelope();
// Send the message to the web service
Connector->EndMessage(); // Let us read the response
if(FAILED(Reader.CreateInstance(__uuidof(SoapReader30)))){
AfxMessageBox("Create SOAP Reader Failed!");
return;
} // Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
// Display the result
try{
IXMLDOMElementPtr elm = Reader->GetRpcResult();
VARIANT_BOOL hasChild;
IXMLDOMNodePtr pNode;
BSTR bstrName, bstrText;
if(elm->hasChildNodes(&hasChild))
{
IXMLDOMNodeListPtr nodes;
elm->get_childNodes(&nodes);
long lNodeLen;
nodes->get_length(&lNodeLen);
for(int i = 0; i < lNodeLen; ++i)
{
nodes->get_item(i, &pNode);
pNode->get_nodeName(&bstrName);
pNode->get_text(&bstrText);
sprintf(buf, "%s = %s", (const char*)bstrName,
(const char*)bstrText);
AfxMessageBox(buf);
}
}
}
catch(_com_error& ce)
{
CString str;
str.Format("COM Error :(%08X)%s", ce.Error(), ce.ErrorMessage());
AfxMessageBox(str); }
}
catch(_com_error& ce)
{
CString str;
str.Format("COM Error :(%08X)%s", ce.Error(), ce.ErrorMessage());
AfxMessageBox(str);
return;
}
}