求救,关于PB调用webservice中传xml格式字符串

孤独潇湘 2017-03-20 01:07:57
小弟最近在研究webservice
pb11.5
webservice:http://221.131.80.221:8091/THSS/services/DrugService?wsdl
其中customer函数三个string参数,arg2要求为xml格式字符串
我写的代码如下:
Long ll_log
SoapConnection lc_soap_conn
mydrugserviceporttypeport proxy_obj
//webservice接口
lc_soap_conn = create SoapConnection //Instantiated connection
ll_log = lc_soap_conn.SetOptions("SoapLog=~"mySoapLog.log~"")
IF lc_soap_conn.CreateInstance(proxy_obj, "mydrugserviceporttypeport","http://221.131.80.221:8091/THSS/services/DrugService?wsdl") <> 0 THEN
MessageBox("提示","webservice接口连接出错!")
END IF
string compCode="***********"
string pwd="***************"
string data="<?xml version=~'1.0~' encoding=~'utf-8~'?><DATAS><DATA><UNIT_NAME>江苏九州通医药有限公司</UNIT_NAME><UP_USER>************</UP_USER><UNIT_TYPE>1</UNIT_TYPE><CERT_NO>**********</CERT_NO><CERT_VALID>2017-04-01</CERT_VALID><TAX_CODE>***********</TAX_CODE><UNIT_RANGE>***************</UNIT_RANGE><BUS_TYPE>0</BUS_TYPE><UNIT_ADD>南京市江宁经济开发区殷华街476号</UNIT_ADD><UNIT_CONT>王**</UNIT_CONT><CONT_PHONE>025********</CONT_PHONE></DATA></DATAS>"
string ll_ret
ll_ret=proxy_obj.customer(compCode,pwd,data)
messagebox("",ll_ret)

DESTROY proxy_obj
DESTROY lc_soap_conn



data字符串在mySoapLog.log中<>均不显示了,变成了“”“<?xml version='1.0' encoding='utf-8'?>”


程序出现错误
Application terminated
Error:The given SOAPAction'
http://service.dataupload.thss.keyu.com/#customer does not match an operation

求救
...全文
2474 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lianxiweixiao 2017-03-24
  • 打赏
  • 举报
回复
xml串好像要用这个样处理下 <![CDATA[xml内容]]> 忽略转义字符
TheLittlePrince 2017-03-21
  • 打赏
  • 举报
回复
有时候用pb调用webservice是一件很蛋疼的事情,你是不是没把pbsoapclient115.pbd这些需要用的pbd动态库啥的加到里面来,如果不是这个原因,换个方式吧。 --首先把你要传的xml数据拼好了 String compCode = "***********" String pwd = "***************" String ls_xml,ls_br = '~r~n' String Data Data = "<?xml version=~'1.0~' encoding=~'utf-8~'?>"+ls_br Data+= "<DATAS>"+ls_br Data+= "<DATA>"+ls_br Data+= "<UNIT_NAME>江苏九州通医药有限公司</UNIT_NAME>"+ls_br Data+= "<UP_USER>************</UP_USER>"+ls_br Data+= "<UNIT_TYPE>1</UNIT_TYPE>"+ls_br Data+= "<CERT_NO>**********</CERT_NO>"+ls_br Data+= "<CERT_VALID>2017-04-01</CERT_VALID>"+ls_br Data+= "<TAX_CODE>***********</TAX_CODE>"+ls_br Data+= "<UNIT_RANGE>***************</UNIT_RANGE>"+ls_br Data+= "<BUS_TYPE>0</BUS_TYPE>"+ls_br Data+= "<UNIT_ADD>南京市江宁经济开发区殷华街476号</UNIT_ADD>"+ls_br Data+= "<UNIT_CONT>王**</UNIT_CONT>"+ls_br Data+= "<CONT_PHONE>025********</CONT_PHONE>"+ls_br Data+= "</DATA>"+ls_br Data+= "</DATAS>" --然后用soapui把wsdl的具体格式抓下来,你问题里的customer 方法如下 ls_xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.dataupload.thss.keyu.com/">'+ls_br ls_xml += '<soapenv:Header/>'+ls_br ls_xml += '<soapenv:Body>'+ls_br ls_xml += '<ser:customer>'+ls_br ls_xml += '<ser:arg0>'+compCode+'</ser:arg0>'+ls_br ls_xml += '<ser:arg1>'+pwd+'</ser:arg1>'+ls_br ls_xml += '<ser:arg2><![CDATA['+Data+']]></ser:arg2>'+ls_br ls_xml += '</ser:customer>'+ls_br ls_xml += '</soapenv:Body>'+ls_br ls_xml += '</soapenv:Envelope>' --再然后用http的post方式直接把这一大串给丢过去。试试吧,我刚试了一下返回结果是"0接收失败:未授权",应该是通的 String as_approve,as_env,Http_Name,result Long ll_length,li_create Time ldt_now as_approve = '' OLEObject http Http_Name = 'http://221.131.80.221:8091/THSS/services/DrugService?wsdl' http = Create OLEObject li_create = http.ConnectToNewObject( "Msxml2.XMLHTTP.6.0") If li_create <> 0 Then li_create = http.ConnectToNewObject( "Msxml2.XMLHTTP.3.0") End If ll_length = Len(ls_xml) http.Open("POST",Http_Name,True) http.setRequestHeader("Content-Type","text/xml;charset=UTF-8") http.setRequestHeader("Content-Length",String(ll_length)) http.setRequestHeader("Authorization","auth="+as_approve) ldt_now = Now() http.Send(ls_xml) Do While http.readyState <> 4 Yield() If Abs(SecondsAfter(ldt_now,Now())) > 20 Then http.abort() result = '20秒内未收到返回信息,程序超时返回,请稍候重新提交数据!' http.DisconnectObject() Destroy http End If Loop result = http.responseText http.DisconnectObject() Destroy http

663

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder Web 应用
社区管理员
  • Web 应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧