GSOAP:添加附件
GSOAP对于附件的处理非常好,可以很灵活的修改附件各部分,也可以偷懒让GSOAP自动生成所需部分~不错~
下面是一堆在测试GSOAP加附件时用到的乱码,就放这里作记录吧~
//
attachment
// if(packet->m_uiContentLen > 0 && packet->m_pContent != NULL)
// {
// soap_set_mime(req.soap, NULL, NULL);
// // if(soap_set_mime_attachment(req.soap, packet->m_pContent, packet->m_uiContentLen, SOAP_MIME_BINARY, "application/vnd.wap.multipart.related", "<KH-MMS-SMIL>", NULL, NULL) != SOAP_OK)
// // if(soap_set_mime_attachment(req.soap, packet->m_pContent, packet->m_uiContentLen, SOAP_MIME_NONE, "text/plain", "<slide1.txt>", "slide1.txt", NULL) != SOAP_OK)
// // if(soap_set_mime_attachment(req.soap, packet->m_pContent, packet->m_uiContentLen, SOAP_MIME_BASE64, "image/png", "<1001417929.27019.9.camel@spectrolite>", "corner-bottomright.png", "attachment; filename=corner-bottomright.png") != SOAP_OK)
// if(soap_set_mime_attachment(req.soap, const_cast<char*>(str.c_str()), str.size(), SOAP_MIME_NONE, "application/vnd.wap.multipart.related; charset=utf-8; boundary=\"----=_Part_24362_271418.1110357304160\"; type=\"application/smil\"; start=\"<KM-MMS-SMIL>\"", NULL, NULL, NULL) != SOAP_OK)
// {
// ACEX_LOG_OS(LM_WARNING, "<CCoreMsgTask::OnClientTaskMMSSendMessage>Add attachment to MIME failed." << std::endl);
// }
// }
soap_set_mime(req.soap, NULL, NULL);
for (Packet::TContentVector::const_iterator it = packet -> m_vctContent.begin(); it != packet -> m_vctContent.end(); ++ it)
{
if (soap_set_mime_attachment(req.soap, it -> m_pData, it -> m_uiSize, soap_mime_encoding(it -> m_ucEncoding), it -> m_strType.c_str(), (it -> m_strID.empty() ? NULL : it -> m_strID.c_str()), (it -> m_strLocation.empty() ? NULL : it -> m_strLocation.c_str()), (it -> m_strDesc.empty() ? NULL : it -> m_strDesc.c_str())) != SOAP_OK)
{
ACEX_LOG_OS(LM_WARNING, " <CCoreMsgTask::OnClientTaskMMSSendMessage>Add attachment to MIME failed. " << std::endl);
}
}
// if(packet->m_uiContentLen > 0 && packet->m_pContent != NULL)
// {
// soap_set_mime(req.soap, NULL, NULL);
// // if(soap_set_mime_attachment(req.soap, packet->m_pContent, packet->m_uiContentLen, SOAP_MIME_BINARY, "application/vnd.wap.multipart.related", "<KH-MMS-SMIL>", NULL, NULL) != SOAP_OK)
// // if(soap_set_mime_attachment(req.soap, packet->m_pContent, packet->m_uiContentLen, SOAP_MIME_NONE, "text/plain", "<slide1.txt>", "slide1.txt", NULL) != SOAP_OK)
// // if(soap_set_mime_attachment(req.soap, packet->m_pContent, packet->m_uiContentLen, SOAP_MIME_BASE64, "image/png", "<1001417929.27019.9.camel@spectrolite>", "corner-bottomright.png", "attachment; filename=corner-bottomright.png") != SOAP_OK)
// if(soap_set_mime_attachment(req.soap, const_cast<char*>(str.c_str()), str.size(), SOAP_MIME_NONE, "application/vnd.wap.multipart.related; charset=utf-8; boundary=\"----=_Part_24362_271418.1110357304160\"; type=\"application/smil\"; start=\"<KM-MMS-SMIL>\"", NULL, NULL, NULL) != SOAP_OK)
// {
// ACEX_LOG_OS(LM_WARNING, "<CCoreMsgTask::OnClientTaskMMSSendMessage>Add attachment to MIME failed." << std::endl);
// }
// }
soap_set_mime(req.soap, NULL, NULL);
for (Packet::TContentVector::const_iterator it = packet -> m_vctContent.begin(); it != packet -> m_vctContent.end(); ++ it)
{
if (soap_set_mime_attachment(req.soap, it -> m_pData, it -> m_uiSize, soap_mime_encoding(it -> m_ucEncoding), it -> m_strType.c_str(), (it -> m_strID.empty() ? NULL : it -> m_strID.c_str()), (it -> m_strLocation.empty() ? NULL : it -> m_strLocation.c_str()), (it -> m_strDesc.empty() ? NULL : it -> m_strDesc.c_str())) != SOAP_OK)
{
ACEX_LOG_OS(LM_WARNING, " <CCoreMsgTask::OnClientTaskMMSSendMessage>Add attachment to MIME failed. " << std::endl);
}
}
<---------------看不见的分割线----------------------->
今天测试了ISAG的MMS接口,一切顺利~
电信对于ISAG是否支持SMIL格式,自己也没有底--“SMIL好像不支持的,你们测试一下。。。”从理论上将,如果ISAG仅仅是透传SOAP附带的各附件,那么附件是何种格式就和ISAG没有关系了,而要看终端是否支持了。
因此,在多附件下发成功的情况下,我们作了SMIL格式的测试--PASS!
报文在 这里,供参考。