是不是返回值设置String,包含XML,
然后客户端自己解析?

解决方案 »

  1.   

    把返回的类型用单独的UserConfig.java来写
      

  2.   

    怎么用Soap Toolkit调用呢?
      

  3.   

    HTML Components (HTC) +JS
    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 技术
      

  4.   

    Server端采用AXIS,客户端采用VC来调用。
    客户端需要返回自定义类型的数据,一直无法正常调用成功,如果返回非自定义的数据则可以调用成功在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;
    }
    }
      

  5.   

    用vc调用不用搞的那么麻烦的,用gsoap生成客户端代码,很快搞定的说