我正在尝试使用一个api,并试图将此代码转换为密码。
<?php
$client = new SoapClient(
"http://trial.black011.com/retailer/Black011SvcDemo.wsdl”,
array( "trace" => 1,
"exceptions" => 0)
);
try {
$arr = $client->recharge( ‘TestID, "TestPassword", "BKLD", “1234567890”,
10, "Any Comment1 of You" );
echo 'error_code' . $arr['error_code'];
echo 'error_msg' . $arr['error_msg'];
echo 'tx_id' . $arr['tx_id'];
echo 'comment1' . $arr['comment1'];
}catch (SoapFault $exception) {
echo "Error Code:" . $exception->getCode();
echo "Error Message:" . $exception->getMessage();
}
?>我正在使用下面的代码来使用api
<cfinvoke webservice="http://trial.black011.com/retailer/Black011SvcDemo.wsdl" method="recharge" returnvariable="res" refreshwsdl="true" >
<cfinvokeargument name="user_id" value="TestID">
<cfinvokeargument name="passwd" value="TestPassword">
<cfinvokeargument name="prod_id" value="BKLD">
<cfinvokeargument name="mdn" value="1112223333">
<cfinvokeargument name="amount" value="10">
<cfinvokeargument name="comment1" value="10">
</cfinvoke>我也试过-
<cfscript>
ws = createObject("webservice", "http://trial.black011.com/retailer/Black011SvcDemo.wsdl");
writeDump(ws);
result = ws.recharge( "TestID", "TestPassword", "BKLD", "19112223333", 10.00 );
writeDump(result);
</cfscript>但每次我试着克服错误-
无法找到带有参数{}的Web服务操作重新充电。有人能发现我的密码有什么问题吗?
发布于 2014-07-23 11:11:51
我有一个代码,似乎是在我测试它的时候工作。
<cfsavecontent variable="soapBody">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:black011">
<soapenv:Header/>
<soapenv:Body>
<urn:recharge soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<user_id xsi:type="xsd:string">test</user_id>
<passwd xsi:type="xsd:string">twawd</passwd>
<prod_id xsi:type="xsd:string">"BKLD"</prod_id>
<mdn xsi:type="xsd:string">"1234567890"</mdn>
<amount xsi:type="xsd:float">20.0</amount>
<comment1 xsi:type="xsd:string">"test"</comment1>
</urn:recharge>
</soapenv:Body>
</soapenv:Envelope>
</cfoutput>
</cfsavecontent>
<cfhttp url="http://trial.black011.com/retailer/OpenSvc.php" method="post" result="httpResponse">
<cfhttpparam type="header" name="SOAPAction" value="http://trial.black011.com/retailer/OpenSvc.php/recharge" />
<cfhttpparam type="header" name="accept-encoding" value="no-compression" />
<cfhttpparam type="xml" value="#trim( soapBody )#" />
</cfhttp>
<cfif find( "200", httpResponse.statusCode )>
<cfset soapResponse = xmlParse( httpResponse.fileContent ) />
<cfdump var="#soapResponse#">
</cfif>发布于 2014-07-05 13:38:01
查看ws变量转储,方法recharge接受9个参数:
recharge(java.lang.String,
java.lang.String,
java.lang.String,
java.lang.String,
float,
javax.xml.rpc.holders.StringHolder,
javax.xml.rpc.holders.StringHolder,
javax.xml.rpc.holders.StringHolder,
javax.xml.rpc.holders.StringHolder) returns void 下面的代码似乎工作得很好:
<cfscript>
wsargs = {};
wsargs.refreshwsdl = "Yes";
ws = createObject("webservice",
"http://trial.black011.com/retailer/Black011SvcDemo.wsdl",
wsargs);
result = ws.recharge("TestID",
"TestPassword",
"BKLD",
"19112223333",
10.0,
"test",
"test",
"test",
"test");
</cfscript>希望这能帮上忙
发布于 2014-07-06 08:08:51
在您的问题中,您说明了具体的方法如下
result = ws.recharge( "TestID", "TestPassword", "BKLD", "19112223333", 10.00 );其中有5个论点。WSDL读取
<message name="rechargeRequest">
<part name="user_id" type="xsd:string"/>
<part name="passwd" type="xsd:string"/>
<part name="prod_id" type="xsd:string"/>
<part name="mdn" type="xsd:string"/>
<part name="amount" type="xsd:float"/>
<part name="comment1" type="xsd:string"/>
</message>有六个论点。您需要为第6个参数指定一些内容,通常使用WSDL,参数帮助以与函数名称相同的方式定义函数。没有任何可选的论据。这给出了应该工作的下列内容
result = ws.recharge(
"TestID",
"TestPassword",
"BKLD",
"19112223333",
10.00,
"Some comment here"
);https://stackoverflow.com/questions/24582689
复制相似问题