gsoap HTTP GET method not implemented错误的解决方法

      用gSOAP开发Web Service服务端,按照gsoap的User's Guide的sample,自己仿着写了个例子,但是在浏览器上输入: http://localhost:18083/
访问的网页显示

 
  
XML code
<? 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:tmsc ="urn:tmsc" >
-
< SOAP-ENV:Body >
-
< SOAP-ENV:Fault SOAP-ENV:encodingStyle ="http://schemas.xmlsoap.org/soap/encoding/" >
< faultcode > SOAP-ENV:Client </ faultcode >
< faultstring > HTTP GET method not implemented </ faultstring >
</ SOAP-ENV:Fault >
</ SOAP-ENV:Body >
</ SOAP-ENV:Envelope >


根据gSOAP文档所说,你需要设置soap.fget回调函数。例如:
你在你的main函数中的soap_init(&soap);的下面加入:   
soap.fget  =  http_get; 即:
soap_init(&soap); 
soap.fget = http_get;
m = soap_bind(&soap, NULL, 18083, 100);

 
  
int http_get(strcut soap * soap)
{
FILE
* fd = NULL;
fd = fopen( " ns.wsdl " , " rb " ); // open WSDL file to copy
if ( ! fd)
{
return 404 ; // return HTTP not found error
}
soap
-> http_content = " text/xml " ; // HTTP header with text /xml content
soap_response(soap,SOAP_FILE);
for (;;)
{
size_t r
= fread(soap -> tmpbuf, 1 , sizeof (soap -> tmpbuf), fd);
if ( ! r)
{
break ;
}
if (soap_send_raw(soap, soap -> tmpbuf, r))
{
break ; // cannot send, but little we can do about that
}
}
fclose(fd);
soap_end_send(soap);
return SOAP_OK;
}

编译后在浏览器中输入 http://localhost:18083/ 连接成功。

附:
关于gsoap的使用心得可以参考这篇http://www.cppblog.com/qiujian5628/archive/2008/06/19/54019.html

转载于:https://www.cnblogs.com/Laokong-ServiceStation/archive/2011/04/29/2032331.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值