http://125.40.47.218:8888/zgyb_lc/services/YBService?wsdl
URL地址是这个
调用的时候接收不到返回的消息 不知道啥原因?
ISoapSerializerPtr Serializer;
 ISoapReaderPtr Reader;
 ISoapConnectorPtr Connector;
 
 // Connect to the service
 Connector.CreateInstance(__uuidof(HttpConnector30));
  Connector->Property["EndPointURL"] = "http://125.40.47.218:8888/zgyb_lc/services/YBService?wsdl";
 Connector->Connect();
 MessageBox("1");
 
 // Begin message
 Connector->Property["SoapAction"] = "http://schemas.xmlsoap.org/wsdl/soap";
 Connector->BeginMessage();
 MessageBox("2");
 // Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer30));
 
 // 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("login","http://schemas.xmlsoap.org/wsdl/","NONE","");
 Serializer->StartElement("ddyljg","hhttp://schemas.xmlsoap.org/wsdl/","NONE","");///http://webservice.yb.erixin.com/
 Serializer->WriteString((char*)_bstr_t(ddyljg));
 MessageBox("3");
 Serializer->EndElement();
 Serializer->StartElement("mcCString","http://schemas.xmlsoap.org/wsdl/","NONE","");//http://webservice.yb.erixin.com/
 Serializer->WriteString((char*)_bstr_t(mcCString));
 MessageBox("4");
 Serializer->EndElement();
 Serializer->EndElement();
 Serializer->EndBody();
 MessageBox("5");
 Serializer->EndEnvelope();
 MessageBox("6");
 // Send the message to the web service
 Connector->EndMessage();      
 MessageBox("7");
 // Let us read the response
 Reader.CreateInstance(__uuidof(SoapReader30));
 MessageBox("8");
 // Connect the reader to the output stream of the connector
 Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
 MessageBox("9");
 // Display the result
 //
 /*char *ReardWX = new char[ strlen( Reader->RpcResult->text ) + 1 ];
 strcpy( ReardWX, Reader->RpcResult->text );
return ReardWX;*/
 printf("Answer: %s\n", (const char*)Reader->RpcResult->text);
 MessageBox("10");
// MessageBox((const char*)Reader->RpcResult->text);
// return (char*)_bstr_t(sRmsg);
  MessageBox((const char*)Reader->Body->xml);
    MessageBox((const char*)Reader->RpcResult->text);
    return (const char*)Reader->RpcResult->text;

解决方案 »

  1.   

    用wsdl结尾的怎么回事你需要访问的URL地址呢?wsdl只是查看数据结构的啊。
    我已经在VC6下实现了Web Services的数据下载,没有问题啊。返回的是XML数据流,按照XML协议和wsdl中定义的参数和返回值格式进行解析就可以了。
      

  2.   

    Connector->Property["EndPointURL"] = "http://125.40.47.218:8888/zgyb_lc/services/YBService";
      

  3.   

    以下是俺用的代码:
    //WEB SERVICE数据下载
    //sWebService--WEB SERVICE地址 如http://192.168.102.168:8080/cbdt/service/seamap
    //sNameSpace--命名空间 如http://seamap.service.jlj.gov
    //sFunction--下载函数,如getShipPositionList
    //arParam--参数数组,包括参数名和参数值
    //Reader--返回数据对象
    //sOutMsg--错误提示信息
    BOOL CWebServiceDownload::SoapDownload(CString sWebService, CString sNameSpace, CString sFunction,CParamArray &arParam,ISoapReaderPtr Reader,CString &sOutMsg)
    {
    // Connect to the service.
    m_Connector->Property["EndPointURL"] = _bstr_t(sWebService);
    m_Connector->Connect();
    // 开始消息

    m_Connector->Property["SoapAction"] = _bstr_t(sWebService);

    m_Connector->BeginMessage();


    // Connect the serializer object to the input stream of the connector object.
    m_Serializer->Init(_variant_t((IUnknown*)m_Connector->InputStream));

    // 创建SOAP消息
    m_Serializer->StartEnvelope("","STANDARD","");
    m_Serializer->StartBody("");

    m_Serializer->StartElement(_bstr_t(sFunction),_bstr_t(sNameSpace),"STANDARD","");
    int nSize = arParam.GetSize();
    for(int i=0; i<nSize; i++)
    {
    SOAP_PARAM sp = arParam.GetAt(i);
    m_Serializer->StartElement(_bstr_t(sp.sParamName),"","STANDARD","");
    m_Serializer->WriteString(_bstr_t(sp.sParamVal));
    m_Serializer->EndElement();
    }
    m_Serializer->EndElement();
    m_Serializer->EndBody();
    m_Serializer->EndEnvelope();

    // 将该消息发送给web服务
    try
    {
    m_Connector->EndMessage();     
    }
    catch(_com_error &e)
    {
    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());
    sOutMsg.Format("SOAP下载失败:%s",(const char*)bstrDescription);
    return FALSE;
    }

        // 将reader联接到connector的输出字符串
    VARIANT_BOOL vb = Reader->Load(_variant_t((IUnknown*)m_Connector->OutputStream), "");
    if(vb == -1)
    return TRUE;
    return FALSE;
    }
      

  4.   

    刚开始接触webservice调用 真是摸不着头绪
      

  5.   

    文本service有在客户端调用应该和其他DLL没有两样
      

  6.   

    其中一个调用是这样的:
    BOOL CWebServiceDownload::DownloadSavReportInfo(COleDateTime tStartTime,COleDateTime tEndTime,CString sShipTypeCode,CString sDangerTypeCode,CString &sOutMsg)
    {
    ISoapReaderPtr Reader;
    Reader.CreateInstance(__uuidof(SoapReader30));
    URLCONFIG uc = theApp.m_sysINIFile.GetURLConfig();
    //构造参数
    CParamArray arParam;
    SOAP_PARAM sp;
    sp.sParamName = "username";
    sp.sParamVal = GetEncryptAccount();
    arParam.Add(sp);
    sp.sParamName = "password";
    sp.sParamVal = GetEncryptPass();
    arParam.Add(sp);
    sp.sParamName = "starttime";
    sp.sParamVal = tStartTime.Format("%Y-%m-%d %H:%M:%S");
    arParam.Add(sp);
    sp.sParamName = "endtime";
    if(tEndTime.m_dt > 0.1)
    sp.sParamVal = tEndTime.Format("%Y-%m-%d %H:%M:%S");
    else
    sp.sParamVal = "";
    arParam.Add(sp);
    sp.sParamName = "shiptype";
    sp.sParamVal = sShipTypeCode;
    arParam.Add(sp);
    sp.sParamName = "dangercode";
    sp.sParamVal = sDangerTypeCode;
    arParam.Add(sp); //进行SOAP下载
    BOOL bReader = SoapDownload(uc.sWebService,uc.sNamespace,uc.sSavReport,arParam,Reader,sOutMsg);
      

  7.   

    如果webservice返回有结构体该怎么取呢?
      

  8.   

    BOOL bReader = SoapDownload(uc.sWebService,uc.sNamespace,uc.sAISBase,arParam,Reader,sOutMsg);
    if(!bReader)
    {
    sOutMsg = "DownloadAISBaseInfo:SOAP下载失败。";
    return FALSE;
    }
    //下载数据解析////////////////////
    CStringList sqlStrList;//形成的插入语句
    IXMLDOMNodeListPtr childNodeList = Reader->RpcResult->GetchildNodes();
    long len = childNodeList->Getlength();//记录的数量
    for(int i=0; i<len; i++)
    {
    IXMLDOMNodePtr nodePtr = childNodeList->Getitem(i);
    IXMLDOMNodeListPtr valNodeList = nodePtr->GetchildNodes();
    long num = valNodeList->Getlength();//字段的数量
    CString sInfo = (const char*)nodePtr->GetnodeName();
    SOAP_AISBASE sa;
    for(int j=0; j<num; j++)
    {
    IXMLDOMNodePtr valPtr = valNodeList->Getitem(j);
    CString sNodeName = (const char*)(valPtr->GetnodeName());
    sNodeName.MakeUpper();
    CString sVal = (const char*)(valPtr->text);
    if(sNodeName == "AISCODE")
    sa.sBaseCode = sVal;
    else if(sNodeName == "AISNAME")
    sa.sBaseName = sVal;
    else if(sNodeName == "SERVICEREGION")
    sa.sSerivceRegion = sVal;
    else if(sNodeName == "ADDRESS")
    sa.sAddress = sVal;
    }
    CString sSql;
    sSql.Format("INSERT INTO AIS_BASE(AIS_BASE_CODE,AIS_BASE_NAME, SERVICEREGION, ADDRESS) values('%s','%s','%s','%s')", 
    sa.sBaseCode,sa.sBaseName,sa.sSerivceRegion,sa.sAddress);
    sqlStrList.AddTail(sSql);
    }
      

  9.   

      SOAP_AISBASE  是定义的跟返回结构体结构一样的结构体吗?