Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3423502
  • 博文数量: 864
  • 博客积分: 14125
  • 博客等级: 上将
  • 技术积分: 10634
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-27 16:53
个人简介

https://github.com/zytc2009/BigTeam_learning

文章分类

全部博文(864)

文章存档

2023年(1)

2021年(1)

2019年(3)

2018年(1)

2017年(10)

2015年(3)

2014年(8)

2013年(3)

2012年(69)

2011年(103)

2010年(357)

2009年(283)

2008年(22)

分类: 系统运维

2011-06-08 21:07:47

我遇到这个问题,因为是用qt开发,使用了第三方的gsoap进行设计,结果总是连不通服务器,但是去掉这个就正常工作了,所以可以断定是gsoap代码对于Authorization处理部分的代码的问题。于是仔细研究终于有所发现,原来真的没有做处理,只能自己加代码处理

例如:服务器端设计,
using System.Web.Services.Protocols; public class AuthHeader : SoapHeader { public string Username; public string Password; }

以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

POST /webservice/service1.asmx HTTP/1.1 Host: Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http:///GetTest" string string HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length string

于是检查soapclient.cpp文件中的soap_call___ns2__GetTest函数,发现调用了soap_serialize___ns2__GetTest函数
再跟进去发现,没有处理header,于是在
soap_serialize___ns2__GetTest(soap, &soap_tmp___ns2__GetTest);之后添加 soap->header=soap_tmp___ns2__GetTest.ns1__GetTest->soap->header;

因为header是在request结构体中带的,调用时
struct soap soap; soap_init(&soap); struct SOAP_ENV__Header header; std::string user="test"; std::string passwd="123456"; header.ns1__AutherHeader_=new ns1__AutherHeader; header.ns1__AutherHeader_->username = &user; header.ns1__AutherHeader_->userpwd = &passwd; soap.header= &header;
_ns1__GetTest *quote = new _ns1__GetTest; _ns1__GetTestResponse *response = new _ns1__GetTestResponse; quote->soap=&soap;
soapObj.__ns2__GetTest(quote, response);

就ok了
阅读(2290) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~