質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
SOAP

SOAP(Simple Object Access Protocol)はウェブサービス実装においての構造化された情報をやり取りするためのプロトコル規定です。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

0回答

1534閲覧

PHPでSOAP APIに接続する。

LearnersHigh2

総合スコア0

SOAP

SOAP(Simple Object Access Protocol)はウェブサービス実装においての構造化された情報をやり取りするためのプロトコル規定です。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2020/09/18 15:27

非常に初歩的な質問なのですが、
SOAP APIにPHPで接続することができず困っています。
SOAPのサーバの仕様によって違うのでは?

と思いつつ、何か勘違いをしている可能性を感じ、ヒントをいただけると大変助かります。
以下、コードになります。

php

1<?php 2$client = new SoapClient('https://hogehoge.co.jp/V1/API.svc?wsdl'); 3$client->__setLocation('https://hogehoge.co.jp/V1/API.svc'); 4 5 6$api_key = new SoapHeader('API_KEY','xxxxxxxxxxxxxxxxxx'); 7$api_token = new SoapHeader('API_TOKEN', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); 8 9$client->__setSoapHeaders($api_key); 10$client->__setSoapHeaders($api_token); 11 12class GetLeadList extends SoapParam 13{ 14 public $Id; 15 public $StartDate; 16 public $EndDate; 17} 18 19$params = new stdClass(); 20$params->DealershipId = 1; 21$params->StartDate = '2020-09-10T00:00:00Z'; 22$params->EndDate = '2020-09-10T00:00:00Z'; 23 24try { 25 $client->GetLeadList(new GetLeadList()); 26} catch (Exception $e) { 27 var_dump($e); 28}

すると、以下のようなエラーが出てきます。

object(SoapFault)#5 (9) { ["message":protected]=> string(429) "The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs." ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(25) "/home/tterashima/soap.php" ["line":protected]=> int(27) ["trace":"Exception":private]=> array(1) { [0]=> array(5) { ["file"]=> string(25) "/home/tterashima/soap.php" ["line"]=> int(27) ["function"]=> string(6) "__call" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" } } ["previous":"Exception":private]=> NULL ["faultstring"]=> string(429) "The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs." ["faultcode"]=> string(22) "a:InternalServiceFault" }

一応、関数リストに関しては以下のように取得できることを確認できています。

array(2) { [0]=> string(44) "GetLeadResponse GetLead(GetLead $parameters)" [1]=> string(56) "GetLeadListResponse GetLeadList(GetLeadList $parameters)" }

以上、よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

sazi

2020/09/19 00:49

内部エラーだから詳細はログ見てね、と言われてますけど、その情報は無いのですか?
LearnersHigh2

2020/09/19 03:12

外部のAPIなので、見れていないです…orz
LearnersHigh2

2020/09/22 01:39

soapFaultの中身はエラーとして出したものそのままになります
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問