求大神帮忙写个例子让我参考下,中国移动的短信彩信API网址是http://117.79.237.3:8060/webservice.asmx,但不知道该怎么样,我想用MFC写一个短信网关,往移动服务器发数据时不知道该怎么调用,大神们给个例子是最好的了

解决方案 »

  1.   

    void WebServiceSoapProxy::WebServiceSoapProxy_init(soap_mode imode, soap_mode omode)
    { soap_imode(this, imode);
    soap_omode(this, omode);
    soap_endpoint = NULL;
    static const struct Namespace namespaces[] =
    {
    {"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://www.w3.org/2003/05/soap-envelope", NULL},
    {"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://www.w3.org/2003/05/soap-encoding", NULL},
    {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
    {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
    {"ns2", "http://tempuri.org/WebServiceSoap", NULL, NULL},
    {"ns1", "http://tempuri.org/", NULL, NULL},
    {"ns3", "http://tempuri.org/WebServiceSoap12", NULL, NULL},
    {NULL, NULL, NULL, NULL}
    };
    this->namespaces = namespaces;
    }int WebServiceSoapProxy::SendSMS(_ns1__SendSMS *ns1__SendSMS, _ns1__SendSMSResponse *ns1__SendSMSResponse)
    { struct soap *soap = this;
    struct __ns2__SendSMS soap_tmp___ns2__SendSMS;
    const char *soap_action = NULL;
    if (!soap_endpoint)
    soap_endpoint = soap_ServicePoint;
    soap_action = "http://tempuri.org/SendSMS";
    soap->encodingStyle = NULL;
    soap_tmp___ns2__SendSMS.ns1__SendSMS = ns1__SendSMS;
    soap_begin(soap);
    soap_serializeheader(soap);
    soap_serialize___ns2__SendSMS(soap, &soap_tmp___ns2__SendSMS);
    if (soap_begin_count(soap))
    return soap->error;
    if (soap->mode & SOAP_IO_LENGTH)
    { if (soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMS(soap, &soap_tmp___ns2__SendSMS, "-ns2:SendSMS", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap))
     return soap->error;
    }
    if (soap_end_count(soap))
    return soap->error;
    if (soap_connect(soap, soap_endpoint, soap_action)
     || soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMS(soap, &soap_tmp___ns2__SendSMS, "-ns2:SendSMS", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap)
     || soap_end_send(soap))
    return soap_closesock(soap);
    if (!ns1__SendSMSResponse)
    return soap_closesock(soap);
    ns1__SendSMSResponse->soap_default(soap);
    if (soap_begin_recv(soap)
     || soap_envelope_begin_in(soap)
     || soap_recv_header(soap)
     || soap_body_begin_in(soap))
    return soap_closesock(soap);
    ns1__SendSMSResponse->soap_get(soap, "ns1:SendSMSResponse", "");
    if (soap->error)
    return soap_recv_fault(soap, 0);
    if (soap_body_end_in(soap)
     || soap_envelope_end_in(soap)
     || soap_end_recv(soap))
    return soap_closesock(soap);
    return soap_closesock(soap);
    }int WebServiceSoapProxy::SendSMS_USCORER(_ns1__SendSMS_USCORER *ns1__SendSMS_USCORER, _ns1__SendSMS_USCORERResponse *ns1__SendSMS_USCORERResponse)
    { struct soap *soap = this;
    struct __ns2__SendSMS_USCORER soap_tmp___ns2__SendSMS_USCORER;
    const char *soap_action = NULL;
    if (!soap_endpoint)
    soap_endpoint = soap_ServicePoint;
    soap_action = "http://tempuri.org/SendSMS_R";
    soap->encodingStyle = NULL;
    soap_tmp___ns2__SendSMS_USCORER.ns1__SendSMS_USCORER = ns1__SendSMS_USCORER;
    soap_begin(soap);
    soap_serializeheader(soap);
    soap_serialize___ns2__SendSMS_USCORER(soap, &soap_tmp___ns2__SendSMS_USCORER);
    if (soap_begin_count(soap))
    return soap->error;
    if (soap->mode & SOAP_IO_LENGTH)
    { if (soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMS_USCORER(soap, &soap_tmp___ns2__SendSMS_USCORER, "-ns2:SendSMS_R", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap))
     return soap->error;
    }
    if (soap_end_count(soap))
    return soap->error;
    if (soap_connect(soap, soap_endpoint, soap_action)
     || soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMS_USCORER(soap, &soap_tmp___ns2__SendSMS_USCORER, "-ns2:SendSMS_R", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap)
     || soap_end_send(soap))
    return soap_closesock(soap);
    if (!ns1__SendSMS_USCORERResponse)
    return soap_closesock(soap);
    ns1__SendSMS_USCORERResponse->soap_default(soap);
    if (soap_begin_recv(soap)
     || soap_envelope_begin_in(soap)
     || soap_recv_header(soap)
     || soap_body_begin_in(soap))
    return soap_closesock(soap);
    ns1__SendSMS_USCORERResponse->soap_get(soap, "ns1:SendSMS_RResponse", "");
    if (soap->error)
    return soap_recv_fault(soap, 0);
    if (soap_body_end_in(soap)
     || soap_envelope_end_in(soap)
     || soap_end_recv(soap))
    return soap_closesock(soap);
    return soap_closesock(soap);
    }int WebServiceSoapProxy::SendSMSEx(_ns1__SendSMSEx *ns1__SendSMSEx, _ns1__SendSMSExResponse *ns1__SendSMSExResponse)
    { struct soap *soap = this;
    struct __ns2__SendSMSEx soap_tmp___ns2__SendSMSEx;
    const char *soap_action = NULL;
    if (!soap_endpoint)
    soap_endpoint = soap_ServicePoint;
    soap_action = "http://tempuri.org/SendSMSEx";
    soap->encodingStyle = NULL;
    soap_tmp___ns2__SendSMSEx.ns1__SendSMSEx = ns1__SendSMSEx;
    soap_begin(soap);
    soap_serializeheader(soap);
    soap_serialize___ns2__SendSMSEx(soap, &soap_tmp___ns2__SendSMSEx);
    if (soap_begin_count(soap))
    return soap->error;
    if (soap->mode & SOAP_IO_LENGTH)
    { if (soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMSEx(soap, &soap_tmp___ns2__SendSMSEx, "-ns2:SendSMSEx", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap))
     return soap->error;
    }
    if (soap_end_count(soap))
    return soap->error;
    if (soap_connect(soap, soap_endpoint, soap_action)
     || soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMSEx(soap, &soap_tmp___ns2__SendSMSEx, "-ns2:SendSMSEx", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap)
     || soap_end_send(soap))
    return soap_closesock(soap);
    if (!ns1__SendSMSExResponse)
    return soap_closesock(soap);
    ns1__SendSMSExResponse->soap_default(soap);
    if (soap_begin_recv(soap)
     || soap_envelope_begin_in(soap)
     || soap_recv_header(soap)
     || soap_body_begin_in(soap))
    return soap_closesock(soap);
    ns1__SendSMSExResponse->soap_get(soap, "ns1:SendSMSExResponse", "");
    if (soap->error)
    return soap_recv_fault(soap, 0);
    if (soap_body_end_in(soap)
     || soap_envelope_end_in(soap)
     || soap_end_recv(soap))
    return soap_closesock(soap);
    return soap_closesock(soap);
    }int WebServiceSoapProxy::SendSMSEx_USCORER(_ns1__SendSMSEx_USCORER *ns1__SendSMSEx_USCORER, _ns1__SendSMSEx_USCORERResponse *ns1__SendSMSEx_USCORERResponse)
    { struct soap *soap = this;
    struct __ns2__SendSMSEx_USCORER soap_tmp___ns2__SendSMSEx_USCORER;
    const char *soap_action = NULL;
    if (!soap_endpoint)
    soap_endpoint = soap_ServicePoint;
    soap_action = "http://tempuri.org/SendSMSEx_R";
    soap->encodingStyle = NULL;
    soap_tmp___ns2__SendSMSEx_USCORER.ns1__SendSMSEx_USCORER = ns1__SendSMSEx_USCORER;
    soap_begin(soap);
    soap_serializeheader(soap);
    soap_serialize___ns2__SendSMSEx_USCORER(soap, &soap_tmp___ns2__SendSMSEx_USCORER);
    if (soap_begin_count(soap))
    return soap->error;
    if (soap->mode & SOAP_IO_LENGTH)
    { if (soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMSEx_USCORER(soap, &soap_tmp___ns2__SendSMSEx_USCORER, "-ns2:SendSMSEx_R", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap))
     return soap->error;
    }
    if (soap_end_count(soap))
    return soap->error;
    if (soap_connect(soap, soap_endpoint, soap_action)
     || soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns2__SendSMSEx_USCORER(soap, &soap_tmp___ns2__SendSMSEx_USCORER, "-ns2:SendSMSEx_R", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap)
     || soap_end_send(soap))
    return soap_closesock(soap);
    if (!ns1__SendSMSEx_USCORERResponse)
    return soap_closesock(soap);
    ns1__SendSMSEx_USCORERResponse->soap_default(soap);
    if (soap_begin_recv(soap)
     || soap_envelope_begin_in(soap)
     || soap_recv_header(soap)
     || soap_body_begin_in(soap))
    return soap_closesock(soap);
    ns1__SendSMSEx_USCORERResponse->soap_get(soap, "ns1:SendSMSEx_RResponse", "");
    if (soap->error)
    return soap_recv_fault(soap, 0);
    if (soap_body_end_in(soap)
     || soap_envelope_end_in(soap)
     || soap_end_recv(soap))
    return soap_closesock(soap);
    return soap_closesock(soap);
    }这些是什么意思啊 哪位大神能给提供下注释
      

  2.   

    参考一下SOAP协议,封装各个数据,然后按协议发送