Codejie's C++ Space

Using C++

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);
        }
    }




    <---------------看不见的分割线----------------------->

    今天测试了ISAG的MMS接口,一切顺利~
    电信对于ISAG是否支持SMIL格式,自己也没有底--“SMIL好像不支持的,你们测试一下。。。”从理论上将,如果ISAG仅仅是透传SOAP附带的各附件,那么附件是何种格式就和ISAG没有关系了,而要看终端是否支持了。
    因此,在多附件下发成功的情况下,我们作了SMIL格式的测试--PASS!

    报文在这里,供参考。


posted on 2009-08-06 18:01 codejie 阅读(3606) 评论(41)  编辑 收藏 引用 所属分类: C++随笔而已

评论

# re: GSOAP:添加附件 2009-11-04 14:35 xiaobai

你好 你的这个包结构能给我看看么谢谢
jpytu@126.com  回复  更多评论   

# re: GSOAP:添加附件 2009-11-04 14:57 codejie

@xiaobai
不清楚你的需求是什么,可能答复不是你所需要的。
MIME附件打包及其发送并不需要我们自己来封装,GSOAP已经搞定这部分代码了,只要按照其MIME相关函数的使用方法说明,应该不会有问题的。可能要多说的是,如果你的MIME附件有顺序要求,那就需要按照顺序‘添加’到GSOAP附件列表中。
这里建议你先看看GSOAP文档中的MIME部分说明,还有MIME规范。这两部分是实现的基础知识。  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 09:48 xiaobai

你好 你有QQ之类的联系方式吗?
我的QQ 88181776  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 10:04 codejie

@xiaobai
现在是么QQ,么MSN,只有mail了,工作环境所迫啊。。。
我在HANGZHOU,如果你也在,那么长途费可以省了,否则,别电我,很贵的。。。嘿嘿~  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 10:07 xiaobai

呵呵 我在哈尔滨哪 是不敢电你   回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 10:11 xiaobai

那你能不能帮帮我啊 我都发快3周了.....也没出去那 再发不去我就得被炒鱿鱼了
我就是想向网关发个彩信 头和 发送格式不会处理  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 10:46 xiaobai

看来钱不是最重要的啊 你的电话介不介意告诉我
我现在真想向你求助 我是真的不会啊 网上也没有相关内容
帮助文档就看到两个发送函数
soap_set_mime()
soap_set_mime_attachment()
我英语学的不好 也没看出啥实质的东西
....我以前没用这东西 网上相关资料也少 我真的很无助 啊
你要是不帮我 我真的做不出来了
  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 13:51 codejie

@xiaobai
这样,我不知道你所使用的MMS规范是哪份,不同的规范有着不同的定义,如果你们跟局方关系好,还能弄到WSDL文件。
这里我想GSOAP你应该很熟悉了吧,那么你按照规范要求添加相应的头和体部分,这些不是MIME,附件才是MIME,如果你只是发送一个文本消息,可能都用不到MIME了。
你现在的情况是什么样的?是发给网关无响应,还是收到了一个错误应答?建议你先用wirshark抓下报文看看。来确定是否发到对方了,是否对方应答了,要先检查链路情况,然后在进一步定位是报文哪里出问题了。

另:
电话先别了,太贵了~你先看看,不行再说。
哈尔滨不错,我去过的~不过就记得太阳岛和大面包了。。。
  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 14:41 xiaobai

其实我gsoap 一点也不熟啊我也是刚开始接触的 是他们非让我用的我以前都不知道这个软件
gsoap 的包头是如何修改的?
  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 14:43 codejie

@xiaobai
这里建议你先熟悉下GSOAP,然后你就会发现,一切跟SOAP相关的问题就不是问题了,剩下的都是业务问题了。  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 15:17 xiaobai

POST / HTTP/1.1

Host: 192.168.0.43:18030

User-Agent: gSOAP/2.7

Content-Type: multipart/related; boundary="==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B=="; type="application/dime"; start="<SOAP-ENV:Envelope>"

Content-Length: 92205808

Connection: close



--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==

Content-Type: application/dime

Content-Transfer-Encoding: binary

Content-ID: <SOAP-ENV:Envelope>



. .....'....cid:id0.http://www.w3.org/2003/05/soap-envelope.<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xmime4="http://www.w3.org/2004/11/xmlmime" xmlns:x="http://127.0.0.1/mtom_stream_test.xsd" xmlns:m="http://127.0.0.1/mtom_stream_test.wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><m:PutData><x:data><x:item xmime4:contentType="*/*"><xop:Include href="cid:id2"/></x:item></x:data></m:PutData></SOAP-ENV:Body></SOAP-ENV:Envelope>
........~.Tid2.*/*..$..................................................`5..........................................................p<...................................).........................................................................................................................8............................................................................ '..................................................D.......k...p...............................................................0...................................*/*..C..........cid:id2......>......9...........T.~.................................(...........cid:id2.....P............C...C.......................................................................................................................................................................................>E..........>E.........(7......Content-Type: multipart/mixed;
.boundary="526c0d56-4059-40d6-b9fa-66097feaf500"

--526c0d56-4059-40d6-b9fa-66097feaf500
Content-Type: application/octet-stream;
.name="logo1.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
.filename="logo1.png"

.....
uo56pO3wsasMBoPBhL4tCZ3BYDAYDEbnEWYRMBgMBoPBhM5gMBgMBoMJncFgMBgMBhM6g8FgMBgM
JnQGg8FgMJjQGQwGg8FgMKEzGAwGg8FgQmcwGAwGg8GEzmAwGAwGEzqDwWAwGIwew/8PAPOadpxW
YtX/AAAAAElFTkSuQmCC
....

--526c0d56-4059-40d6-b9fa-66097feaf500
Content-Type: application/octet-stream;
.name="mms.smil"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
.filename="mms.smil"

PHNtaWw+DQo8aGVhZD4NCjxtZXRhIG5hbWU9InRpdGxlIiBjb250ZW50PSJ0ZXN0NyIvPg0KPGxh
eW91dD4NCjxyb290LWxheW91dCB3aWR0aD0iMzUyIiBoZWlnaHQ9IjE0NCIvPg0KPHJlZ2lvbiBp
ZD0iSW1hZ2UiIHdpZHRoPSIxNzYiIGhlaWdodD0iMTQ0IiBsZWZ0PSIwIiB0b3A9IjAiIGZpdD0i
bWVldCIvPg0KPHJlZ2lvbiBpZD0iVGV4dCIgd2lkdGg9IjE3NiIgaGVpZ2h0PSIxNDQiIGxlZnQ9
IjE3NiIgdG9wPSIwIiBmaXQ9InNjcm9sbCIvPg0KPC9sYXlvdXQ+DQo8L2hlYWQ+DQo8Ym9keT4N
CjxwYXIgZHVyPSI1cyI+DQo8aW1nIHNyYz0ibG9nbzEucG5nIiByZWdpb249IkltYWdlIi8+DQo8
L3Bhcj4NCjwvYm9keT4NCjwvc21pbD4NCg==

--526c0d56-4059-40d6-b9fa-66097feaf500
  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 15:20 xiaobai

你看这是我的报文 结果和你那差远 了
我估计是header的问题 不过这我不知道怎么改,应该改成什么样  回复  更多评论   

# re: GSOAP:添加附件 2009-11-05 15:55 codejie

@xiaobai
从报文看,你的SOAP报文部分内容都是空的?不清楚你使用的MMS接口规范是怎么定义的,不过想来应该是你SOAP部分组包不对。
GSOAP对SOAP部分的支持还是很好的,一般不需要修改的,我修改纯粹因为WSDL文档定义的不好,被比无奈啊。这里还是建议你先看看GSOAP的使用,然后在看看规范是怎么要求打SOAP-ENV部分报文的。没有规范,我也不清楚SOAP-ENV该什么样的。  回复  更多评论   

# re: GSOAP:添加附件 2009-11-06 20:11 xiaobai

嘻嘻 再帮帮我
POST / HTTP/1.1

Host: 192.168.0.43:18030

User-Agent: gSOAP/2.7

Content-Type: multipart/related; boundary="==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B=="; type="text/xml"; start="<SOAP-ENV:Envelope>"

Content-Length: 14782

Connection: close

SOAPAction: ""



--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==

Content-Type: text/xml; charset=utf-8

Content-Transfer-Encoding: binary

Content-ID: <SOAP-ENV:Envelope>



<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><mm7:DeliverReq><MessageType>MM7-Deliver.req</MessageType><TransactionID>442214</TransactionID><Sender>13951900000</Sender><MM7Version>5.2.0</MM7Version></mm7:DeliverReq></SOAP-ENV:Body></SOAP-ENV:Envelope>

--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==

Content-Type: image/png

Content-Transfer-Encoding: base64

Content-ID: logo1.png



PHNtaWw+DQo8aGVhZD4NCjxtZXRhIG5hbWU9InRpdGxlIiBjb250ZW50PSJ0ZXN0NyIvPg0KPGxh
eW91dD4NCjxyb290LWxheW91dCB3aWR0aD0iMzUyIiBoZWlnaHQ9IjE0NCIvPg0KPHJlZ2lvbiBp
wLni/PRZ3ydH6BRVP0uD6HR16IahE1ofPzJZjTUp327vVdaK4Hv9jIe2ELpIw0iV7vDB/bzPvMM4
hSJRhEIhhCIx8W9U5+d51N4jnOOXQDAYDEbvgwm9vdF7CsCw+Nc27pxyCVVDcq+TuCFcQeBzTOAM
BoPBhM6EHkzyKdQOrrFEJG9BcpBNG1EnbgfADdROcMvzS1IYDAaDCZ0JvTVE7yX2OuEDwJAh4deJ
uo56pO3wsasMBoPBhL4tCZ3BYDAYDEbnEWYRMBgMBoPBhM5gMBgMBoMJncFgMBgMBhM6g8FgMBgM
JnQGg8FgMJjQGQwGg8FgMKEzGAwGg8FgQmcwGAwGg8GEzmAwGAwGEzqDwWAwGIwew/8PAPOadpxW
YtX/AAAAAElFTkSuQmCC

--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==

Content-Type: text/xml

Content-Transfer-Encoding: base64

Content-ID: mms.smil



PHNtaWw+DQo8aGVhZD4NCjxtZXRhIG5hbWU9InRpdGxlIiBjb250ZW50PSJ0ZXN0NyIvPg0KPGxh
eW91dD4NCjxyb290LWxheW91dCB3aWR0aD0iMzUyIiBoZWlnaHQ9IjE0NCIvPg0KPHJlZ2lvbiBp
ZD0iSW1hZ2UiIHdpZHRoPSIxNzYiIGhlaWdodD0iMTQ0IiBsZWZ0PSIwIiB0b3A9IjAiIGZpdD0i
bWVldCIvPg0KPHJlZ2lvbiBpZD0iVGV4dCIgd2lkdGg9IjE3NiIgaGVpZ2h0PSIxNDQiIGxlZnQ9
IjE3NiIgdG9wPSIwIiBmaXQ9InNjcm9sbCIvPg0KPC9sYXlvdXQ+DQo8L2hlYWQ+DQo8Ym9keT4N
CjxwYXIgZHVyPSI1cyI+DQo8aW1nIHNyYz0ibG9nbzEucG5nIiByZWdpb249IkltYWdlIi8+DQo8
L3Bhcj4NCjwvYm9keT4NCjwvc21pbD4NCg==

--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==--  回复  更多评论   

# re: GSOAP:添加附件 2009-11-06 20:13 xiaobai

虽然和你那个很像了 还是无法和网关通信 可能哪出问题了那?
我的这个网关是不需要用户名密码的  回复  更多评论   

# re: GSOAP:添加附件[未登录] 2009-11-06 21:41 codejie

@xiaobai
你收到网关的应答没有?应答的内容是什么?正确嘛?  回复  更多评论   

# re: GSOAP:添加附件 2009-11-10 15:27 xiaobai

嘻嘻 再帮我看下 这是我的soap
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"><SOAP-ENV:Header><mm7:TransactionID">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"><SOAP-ENV:Header><mm7:TransactionID SOAP-ENV:mustUnderstand="1">444165</mm7:TransactionID></SOAP-ENV:Header><SOAP-ENV:Body><mm7:SubmitReq><MM7Version>5.2.0</MM7Version><SenderIdentification><VASPID>9999</VASPID><VASID>400</VASID><SenderAddress>15900044452011</SenderAddress></SenderIdentification><Recipients><To><Number>150150150150</Number></To></Recipients><ServiceCode>4</ServiceCode><DeliveryReport>False</DeliveryReport><Subject>this test</Subject></mm7:SubmitReq></SOAP-ENV:Body></SOAP-ENV:Envelope>
这是网关返回的信息
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header><TransactionID xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" soap-env:mustUnderstand="1">644511</TransactionID></soap-env:Header><soap-env:Body><mm7:VASPErrorRsp xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"><MM7Version>5.2.0</MM7Version><Status><StatusCode>4004</StatusCode></Status></mm7:VASPErrorRsp></soap-env:Body></soap-env:Envelope>
他说验证错误 可能是哪错了?
  回复  更多评论   

# re: GSOAP:添加附件 2009-11-10 16:41 codejie

@xiaobai
恭喜啊~看Header和Body都有数据了,不错~
网关响应的错误是4004,这个你要看手里的接口规范了,先看看这个4004代表什么,如可能就是说‘Sender不存在’或者‘缺少xxx字段’等应用层错误,而这类错误很好解决的。所以,建议赶紧看看规范怎么说的~(我没有你用的接口规范,无法定位错误的。)  回复  更多评论   

# re: GSOAP:添加附件 2009-11-10 17:35 xiaobai

4004 的解释就是验证错误
不过他没给错误描述 能强制调出错误信息吗?  回复  更多评论   

# re: GSOAP:添加附件[未登录] 2009-11-10 21:12 codejie

@xiaobai
验证什么错误?是sender错,还是内容错呢?如果规范没有说明,就只能问网关侧了,应该不会有啥方法“强制调出错误信息”,这些错误完全是协议规范定义的。你到底用的是什么规范啊,哪里定的?应该有错误说明的。  回复  更多评论   

# re: GSOAP:添加附件 2009-11-12 16:45 xiaobai

请问 在gsoap 中 这种节点是怎么加上去的?
<Content href="cid:mms_cid"/>  回复  更多评论   

# re: GSOAP:添加附件[未登录] 2009-11-12 20:19 codejie

@xiaobai
这个是MIME部分吧?如何是,那GSOAP自己会添加的,在添加附件的时候指定的。我不记得手工加过这段。  回复  更多评论   

# re: GSOAP:添加附件 2009-11-13 15:10 xiaobai

网关返回 缺少ContentType节点怎么办 ?
下面是我 的soap包
POST / HTTP/1.1

Host: 192.168.0.64:55603

User-Agent: gSOAP/2.7

Content-Type: multipart/related; boundary="==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B=="; type="text/xml"; start="<SOAP-ENV:Envelope>"

Content-Length: 1049

Connection: close

SOAPAction: ""



--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==

Content-Type: text/xml; charset=utf-8

Content-Transfer-Encoding: binary

Content-ID: <SOAP-ENV:Envelope>



<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"><SOAP-ENV:Header><mm7:TransactionID SOAP-ENV:mustUnderstand="1">444165</mm7:TransactionID></SOAP-ENV:Header><SOAP-ENV:Body><mm7:DeliverReq><MM7Version>5.2.0</MM7Version><SenderIdentification><SenderAddress>15900445201</SenderAddress></SenderIdentification><Sender>15912345678</Sender><LinkedID>6060</LinkedID><ContentType>multipart/mixed</ContentType><Content href="cid: id0"></Content></mm7:DeliverReq></SOAP-ENV:Body></SOAP-ENV:Envelope>

--==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==--  回复  更多评论   

# re: GSOAP:添加附件 2009-11-13 16:44 xiaobai

soap_set_mime_attachment ()这个函数是只挂载附件把
那执行附件放送的方法怎么弄?  回复  更多评论   

# re: GSOAP:添加附件[未登录] 2009-11-14 12:30 codejie

@xiaobai
对于GSOAP来说,附件附上之后,发送过程GSOAP自己会搞定的,就跟没有附件一样的过程。  回复  更多评论   

# re: GSOAP:添加附件 2009-12-24 11:17 lmode

我现在发送一个wap push 的请求,得到错误SOAP 1.1 fault: SOAP-ENV:Server.generalException [no subcode]
""
Detail:
我通过在代码中打印有看到消息发送到服务端,服务端也有返回,现在就是想知道如何打印我发送请求的报文,想看看我打包的soap包有没有问题,我用wireshark抓过包,好像抓不完整...  回复  更多评论   

# re: GSOAP:添加附件 2009-12-24 11:28 lmode

printf("soap len=%d\n",soap.buflen);
printf("soap buf=%s\n",soap.buf);
这2个可以打印出来..
  回复  更多评论   

# re: GSOAP:添加附件 2009-12-24 11:36 codejie

wireshark如果抓的不完整,首先需要考虑的应该是是否发送的完整?因此最好先检查一下发送的代码是否正常。

另:
buf的打印尽量不要用%s方式,虽然buf的内容都是由可见的ASCII组成,但这里还是建议用dumphex方式打印~这样的好处很多,简单说如果你的buf写的不对,一个\0,你就什么都不知道了~  回复  更多评论   

# re: GSOAP:添加附件 2009-12-24 16:53 lmode

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://www.chinatelecom.com.cn/schema/ctcc/wap_push/send/v1_0/local"
xmlns:ns5="http://www.chinatelecom.com.cn/schema/ctcc/wap_push/v1_0"
xmlns:ns4="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1"
xmlns:ns1="http://www.chinatelecom.com.cn/wsdl/ctcc/wap_push/send/v1_0/service"
xmlns:headerNS="http://customeheader.test.com">
<SOAP-ENV:Header>
<headerNS:spId>14100389</headerNS:spId>
<headerNS:spPassword>4B4588F7B29D96D5C9D169F90B03B9DC</headerNS:spPassword>
<headerNS:timeStamp>0212123008</headerNS:timeStamp>
<headerNS:productId>114000000000000001794</headerNS:productId>
<headerNS:SAN>10659233</headerNS:SAN>
<headerNS:transactionId></headerNS:transactionId>
<headerNS:transEnd>0</headerNS:transEnd>
<headerNS:linkId></headerNS:linkId>
<headerNS:OA>tel:+8618906915906</headerNS:OA>
<headerNS:FA>tel:+8618906915906</headerNS:FA>
<headerNS:multicastMessaging>false</headerNS:multicastMessaging>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:sendMessage>
<ns2:addresses>tel:+8618906915906</ns2:addresses>
<ns2:targetURL>www.qq.com</ns2:targetURL>
<ns2:senderAddress>hello</ns2:senderAddress>
<ns2:subject>wap push test</ns2:subject>
<ns2:priority>Normal</ns2:priority>
<ns2:charging>
<description>des</description>
<currency>81</currency>
<amount>82</amount>
<code>83</code>
</ns2:charging>
<ns2:receiptRequest>
<endpoint>http://xxx.xxx.xxx.xxx:5080/isag/North/WPS/WapMessageNotification</endpoint>
<interfaceName>SendSms</interfaceName>
<correlator>1000002220</correlator>
</ns2:receiptRequest>
</ns2:sendMessage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这个是我发送的消息,网关回复的错误信息是soapheader错误  回复  更多评论   

# re: GSOAP:添加附件 2009-12-24 16:55 lmode

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestSOAPHeader
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"
xmlns:ns1="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1">
<ns1:spId>14150389</ns1:spId>
<ns1:productId>114000000000000001794</ns1:productId>
<ns1:timeStamp>0212123008</ns1:timeStamp>
<ns1:spPassword>4B4588F7B29D96D5C9D169F90B03B9DC</ns1:spPassword>
<ns1:OA>tel:+8618959140245</ns1:OA>
<ns1:FA>tel:+8618995140245</ns1:FA>
<ns1:SAN>10659233</ns1:SAN>
</ns1:RequestSOAPHeader>
</soapenv:Header>
<soapenv:Body>
<sendMessage xmlns="http://www.chinatelecom.com.cn/schema/ctcc/wap_push/send/v1_0/local">
<addresses>tel:+8618959140245</addresses>
<targetURL>www.qq.com</targetURL>
<senderAddress>10659233</senderAddress>
<subject>wapPush</subject>
<priority>Normal</priority>
<charging>
<description xmlns="">des</description>
<currency xmlns="">88</currency>
<amount xmlns="">88</amount>
<code xmlns="">88</code>
</charging>
<receiptRequest>
<endpoint xmlns="">http://xxx.xxx.xxx.xxx:8180/webapp/services/WapMessageNotification</endpoint>
<interfaceName xmlns="">SendSms</interfaceName>
<correlator xmlns="">1000002220</correlator>
</receiptRequest>
</sendMessage>
</soapenv:Body>
</soapenv:Envelope>

这个是别人给我的模板,差了一个RequestSOAPHeader 标签,这个是怎样加上去的?  回复  更多评论   

# re: GSOAP:添加附件 2009-12-25 09:43 codejie

别人的模板并不是唯一正确的,尤其在‘域名’的地方是可以随意的。这里建议你所使用的WSDL文件是否和服务端要求的一样。
对于GSOAP来说,如果由WSDL产生的文件符合协议要求,那么你按照正常填充就OK了,不会有太大问题。
当然如果是GSOAP自己产生的文件不符合WSDL文件,那么你就不得不自己添加一些代码了。我这里还有一篇说SOAP如何添加的帖子,请参考'http://www.cppblog.com/codejie/archive/2009/07/13/89972.html'.  回复  更多评论   

# re: GSOAP:添加附件 2010-01-14 15:56 lmode

如何接收带soapheader的消息,我可以接收到soapbody的内容,但是header的确是空值  回复  更多评论   

# re: GSOAP:添加附件 2010-01-14 17:59 codejie

@lmode
如果你使用的是GSOAP的话,这应该不是问题,GSOAP会自动将SOAP报文中的内容分解到相对应的结构中。
或是我理解问题不对,你有更详细的问题描述吗?  回复  更多评论   

# re: GSOAP:添加附件 2010-01-15 09:19 lmode

嗯,是用gsoap的,我客户端发送的消息内容是
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns3="http://www.chinatelecom.com.cn/schema/ctcc/wap_push/v1_0" xmlns:ns2="http://www.chinatelecom.com.cn/schema/ctcc/wap_push/notification/v1_0/local" xmlns:ns4="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1" xmlns:ns1="http://www.chinatelecom.com.cn/wsdl/ctcc/wap_push/notification/v1_0/service"><SOAP-ENV:Header><ns1:NotifySOAPHeader><spRevId>14101163</spRevId><spRevpassword>2EBEC22DBC8D2EF87C3541B78F47EA98</spRevpassword><spId>14101164</spId><SAN>san</SAN><transactionId>transactionId</transactionId><linkId>linkid</linkId></ns1:NotifySOAPHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns2:notifyMessageDeliveryReceipt><ns2:correlator>1234567890</ns2:correlator><ns2:deliveryStatus><address>059188389911</address><status>DeliveredToNetwork</status></ns2:deliveryStatus></ns2:notifyMessageDeliveryReceipt></SOAP-ENV:Body></SOAP-ENV:Envelope>

在服务端soap_serve接收消息完消息后,
可以打印correlator,address,status的值,但是通过soap->header确打不出soap头的相关信息  回复  更多评论   

# re: GSOAP:添加附件 2010-01-15 09:30 codejie

@lmode
不该有你这样的现象的,你查看一下Header对应的structure,报文中Header的内容应该有相应的字段的。  回复  更多评论   

# re: GSOAP:添加附件 2010-01-15 09:41 lmode

struct SOAP_ENV__Header
{
#ifdef WITH_NOEMPTYSTRUCT
char dummy; /* dummy member to enable compilation */
#endif
struct ns4__RequestSOAPHeader* ns4_ReqSoapHeader;
struct ns4__NotifySOAPHeader* ns4_NotifySoapHeader;
};
我用
printf("spRevId=%s\n",soap->header->ns4_NotifySoapHeader->spRevId);打印,程序异常退出,soap->header->ns4_NotifySoapHeader->spRevId按%d打印为0,地址未分配  回复  更多评论   

# re: GSOAP:添加附件 2010-01-15 10:40 codejie

@lmode
我没有关注你使用的协议,只是根据一般协议描述来说,
1.sprevid是可以不存在的,因此,printf前需要检查其值是否存在;
2.根据GSOAP的惯用,sprevid可能是个复合结构,也许不能直接用printf的,建议你检查一下sprevid的结构定义先;
3.如果报文显示sprevid有内容,但结构为NULL,那么就是说你的header并没有解开,也许是没有添加处理Header的代码,GSOAP在头上的处理有些问题,但一般都是由于WSDL文件不准确所致,请参考‘http://www.cppblog.com/codejie/archive/2009/07/13/89972.html’先。  回复  更多评论   

# re: GSOAP:添加附件 2010-01-15 16:28 lmode

我按你给的链接,添加了相关的代码
a->ns4_NotifySoapHeader = soap_in_ns4__NotifySOAPHeader(soap, "-ns1:NotifySOAPHeader", a->ns4_NotifySoapHeader, "");
返回成功,char* spRevId依旧为NULL,但是我跟踪soap_in_ns4__NotifySOAPHeader这个函数进去
在执行if (soap_in_string(soap, "spRevId", &a->spRevId, "xsd:string"))语句的时候,确是失败的,报文中tag=ns1:NotifySOAPHeader,和我函数设置的是一致的.不知道什么原因了..  回复  更多评论   

# re: GSOAP:添加附件头 2010-03-08 17:20 lmode

soap_set_mime(soap, NULL, NULL);
if(soap_set_mime_attachment(soap,NULL,0, SOAP_MIME_8BIT, "multipart/related;start=\"animations.smil\";type=\"application/smil\";boundary=\"SubPart_7452684322002_77645\"","mime head", NULL, NULL) != SOAP_OK)
printf("soap_set_mime_attachment smil failed");
for(AppendixVectoriter it = AppendixVec.begin(); it != AppendixVec.end(); ++ it)
{
if(soap_set_mime_attachment(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)
printf("soap_set_mime_attachment failed");
}

子分隔符SubPart_7452684322002_77645 不起作用.附件头怎么加?  回复  更多评论   

# re: GSOAP:添加附件 2010-03-08 17:43 codejie

@lmode
印象中,分隔符让gsoap自己完成比较好,反正我好像是没有对attachment对象添加这么多参数的。  回复  更多评论   

# re: GSOAP:添加附件头 2010-03-08 18:05 lmode

我现在没找到好办法,就直接自己构造了...  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


公告

Using C++

导航

统计

留言簿(73)

随笔分类(513)

积分与排名

最新评论

阅读排行榜

评论排行榜