免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5804 | 回复: 3
打印 上一主题 下一主题

跪求高手赐教SOAP::data发送中文webservice报文问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-06-13 22:35 |只看该作者 |倒序浏览
#!/usr/bin/perl -w
#use strict;
use SOAP::Lite +trace=>all;
use Encode;
use Encode::CN;
use utf8;
my $line;
my $soap = SOAP::Lite->new( proxy => 'http://webservice.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx');
$soap->default_ns('http://WebXml.com.cn');
$soap->envprefix('soapenv');
$soap->encodingStyle('');

$soap->on_action( sub { return '""'});
#open FILE,"<:encoding(utf","temp_test.xml" or die "";
open FILE,"<temp_test.xml" or die "";
-----temp_test.xml此文件是utf-8编码格式。脚本本身也是utf-8格式
my @Files = <FILE>;
close(FILE);


foreach (@Files){
        chomp;
        s/^\s+|\s$//;
  $line .= $_;

}

my @p = (
                SOAP:ata->name(theIpAddress=> $line)
        );

my $method = SOAP:ata->name('getCountryCityByIp')
                      ->attr({xmlns => 'http://WebXml.com.cn'});
my $som = $soap->call($method => @p);

open FILE ,">teset_ws.xml";
print FILE $som->result;
close(FILE);
    print "\ncall getCountryCityByIp\n";
   
    使用trace跟踪消息发现,$line自动转换成base64Binary编码格式了。。。服务端此字段类型是xsd:string类型
    坑爹呀!!!!咋回事会成样格尼!!!跪求高手赐教~~~~~~~~明明是utf8编码格式 怎么就变成base64了呢?

论坛徽章:
0
2 [报告]
发表于 2012-06-14 21:48 |只看该作者
没有高手么

论坛徽章:
0
3 [报告]
发表于 2013-07-10 16:55 |只看该作者
你来的不是时候,高手都吃饭去了。

论坛徽章:
0
4 [报告]
发表于 2013-09-05 23:34 |只看该作者
本帖最后由 fanwei_2123 于 2013-09-05 23:35 编辑

还是文档靠得住

仔细阅读文档发现居然有一个 这样的函数 $soap->serializer->autotype(0);
这个函数的意思是自动转化类型
修改为autotype(0)关闭自动转化。问题即解决
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP