私はPHPプログラミングの完全な新参ですが、Javaで書かれた私の会社のWebサービスを使用するサンプルのPHP Webサービスクライアントを作成することに取り組んでいます。私たちには2種類のサービスがあります。認証が必要なものとそうでないもの。私はwsdl2phpライブラリを使用して、認証を必要としないサービスと正常に通信しました。PHPとwsdl2phpでSOAPヘッダーを追加
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sen="https://webservices.averittexpress.com/SendWebImageService">
<soapenv:Header xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns:authnHeader soapenv:mustUnderstand="0" xmlns:ns="http://webservices.averittexpress.com/authn">
<Username>xxxxxxxx</Username>
<Password>xxxxxxxx</Password>
</ns:authnHeader>
</soapenv:Header>
私が持っている問題は、私はどのようにwsdl2phpでこれを行うには考えているということですかそれも可能な場合:私たちの安全なサービスは、私はこのようになります私の要求にSOAPヘッダを追加する必要があります。私が現在テストしているPHPファイルは次のとおりです。
<?php
require_once 'LTLRateQuoteService.php';
$rqs = new LTLRateQuoteService();
$info = new ShipmentInfo();
$HeaderSecurity = array("authnHeader"=>array("UserName"=>"xxxxxx",
"Password"=>"xxxxxx",));
$header[] = new SoapHeader("http://schemas.xmlsoap.org/soap/encoding",
"Header",$HeaderSecurity);
$rqs->__setSoapHeaders($header);
$args = new AvtLTLRateQuoteRequest();
$args->AccountNumber = '1234578';
$args->OriginCity = 'Cookeville';
$args->OriginState = 'TN';
$args->OriginZip = '38501';
$args->DestinationCity = 'Morristown';
$args->DestinationState = 'TN';
$args->DestinationZip = '37814';
$args->ShipDate = '12/12/2011';
$args->Customer = 'S';
$args->PaymentType = 'P';
$info->NumPieces = '1';
$info->NumHandling = '1';
$info->CubicFeet = '1';
$info->Items = '1';
$info->TotalItem = '1';
$info->TotalWeight = '100';
$args->ShipmentInfo = $info;
$grq = new getLTLRate();
$grq->arg0 = $args;
$response = $rqs->getLTLRate($grq);
$details = $response->return;
print 'Total Freight Charge: ' . $details->TotalFreightCharge . ' ';
?>
私は何とかこの要求に応じて、ヘッダーにユーザー名とパスワードを添付し、それを行う方法見当がつかないする必要があります。私はwsdl2phpサイトを見ていて、ライブラリの使い方に関するドキュメントはほとんどありません。どんな助けもありがとう。
むしろ、その後のおかげで、
アンドリュー
なぜnewbsがWebサービスに入りますか?または、あなたのシェフがウェブサービスを書くために完全なnewbに頼んでしまうほど巧妙なのでしょうか? –
私はWebサービスを作成していません。私たちはJavaの家です。私たちはJavaでWebサービスを作成しました。 PHPを使用して接続するサービスを使用するクライアントがあります。私は単純にPHPで簡単なクライアントを作成しようとしています。私はセキュリティで保護されていないクライアントを正常に動作させるようにしました。私はちょうど認証を必要とするものに悩まされています。 –
私はこれと同じ問題を抱えています。誰でも助けてくれます。 –