我需要通过PHP使用基于SOAP的Web服务。网址为http://196.6.103.58:9094/PitchControlCenter/PitchControlCenterWithXML?wsdl。
我能够从.NET和JAVA成功完成,但无法通过PHP完成。所描述的Web方法将XML作为参数形式的字符串。 这是我的PHP代码:
<?php
$request= '<?xml version="1.0" encoding="UTF-8"?>
<PaymentRequest>
<Header>
<FileName>erqeqe</FileName>
<ScheduleId>AS23411323</ScheduleId>
<DebitSortCode>050</DebitSortCode>
<DebitAccountNumber>0123456789</DebitAccountNumber>
<ClientId>ERCAS_01</ClientId>
</Header>
<PaymentRecord>
<Beneficiary>salami isah</Beneficiary>
<Amount>1000.00</Amount>
<AccountNumber>0000730988</AccountNumber>
<SortCode>058</SortCode>
<Narration>this is a test</Narration>
</PaymentRecord>
<HashValue></HashValue>
</PaymentRequest>';
$url = "http://196.6.103.58:9094/PitchControlCenter/PitchControlCenterWithXML?wsdl";
$client = new SoapClient($url);
$fcs = $client->__getFunctions();
//$fcs=$client->__getTypes();
$response=$client->uploadPaymentSchedule($request);
var_dump($response); // empty response
?>
在Java中,我将其作为Web服务添加,并且以下代码可以正常工作:
public class NibssPayPlusTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String request ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<PaymentRequest>\n" +
" <Header>\n" +
" <FileName>erqeqe</FileName>\n" +
" <ScheduleId>AS23411323</ScheduleId>\n" +
" <DebitSortCode>050</DebitSortCode>\n" +
" <DebitAccountNumber>0123456789</DebitAccountNumber>\n" +
" <ClientId>ERCAS_01</ClientId>\n" +
" </Header>\n" +
" <PaymentRecord>\n" +
" <Beneficiary>salami isah</Beneficiary>\n" +
" <Amount>1000.00</Amount>\n" +
" <AccountNumber>0000730988</AccountNumber>\n" +
" <SortCode>058</SortCode>\n" +
" <Narration>this is a test</Narration>\n" +
" </PaymentRecord>\n" +
" <HashValue></HashValue>\n" +
"</PaymentRequest>";
System.out.println(uploadPaymentSchedule(request));
}
private static String uploadPaymentSchedule(java.lang.String request) {
com.nibss.nibsspayplus.test.PitchControlCenterWithXML_Service service = new com.nibss.nibsspayplus.test.PitchControlCenterWithXML_Service();
com.nibss.nibsspayplus.test.PitchControlCenterWithXML port = service.getPitchControlCenterWithXMLPort();
return port.uploadPaymentSchedule(request);
}
}
我肯定在PHP中遗漏了一些东西