@@ -29,6 +29,7 @@ class ilSoapClient
2929 public const DEFAULT_CONNECT_TIMEOUT = 10 ;
3030 public const DEFAULT_RESPONSE_TIMEOUT = 5 ;
3131
32+ public const MAX_DIRECTORY_SEARCH_DEPTH = 20 ;
3233 private ilLogger $ log ;
3334 private ilSetting $ settings ;
3435 private ?SoapClient $ client = null ;
@@ -98,12 +99,40 @@ public function init(): bool
9899 $ uri = (new \ILIAS \Data \URI ($ internal_path ));
99100 parse_str ($ uri ->getQuery () ?? '' , $ query );
100101 $ this ->uri = (string ) (isset ($ query ['wsdl ' ]) ?
101- $ uri :
102- $ uri ->withQuery (http_build_query (array_merge ($ query , ['wsdl ' => '' ]))));
102+ $ uri :
103+ $ uri ->withQuery (http_build_query (array_merge ($ query , ['wsdl ' => '' ]))));
103104 } elseif (trim ($ this ->settings ->get ('soap_wsdl_path ' , '' )) !== '' ) {
104105 $ this ->uri = $ this ->settings ->get ('soap_wsdl_path ' , '' );
105106 } else {
106- $ this ->uri = ilUtil::_getHttpPath () . '/public/soap/server.php?wsdl ' ;
107+ $ request_path = ilUtil::_getHttpPath ();
108+ $ depth = 0 ;
109+ if (PHP_SAPI !== 'cli ' ) {
110+ $ script_path = dirname ($ _SERVER ['SCRIPT_FILENAME ' ]);
111+ while ($ depth < self ::MAX_DIRECTORY_SEARCH_DEPTH && !is_file ($ script_path . '/ilias.php ' )) {
112+ $ parent = dirname ($ script_path );
113+ if ($ parent === $ script_path ) {
114+ break ;
115+ }
116+ $ script_path = $ parent ;
117+ $ depth ++;
118+ }
119+ }
120+
121+ if ($ depth > 0 && is_file ($ script_path . '/ilias.php ' )) {
122+ $ url_parts = parse_url ($ request_path );
123+ $ path = $ url_parts ['path ' ] ?? '' ;
124+ $ path_parts = explode ('/ ' , rtrim ($ path , '/ ' ));
125+ $ path_parts = array_slice ($ path_parts , 0 , -$ depth );
126+ $ new_path = implode ('/ ' , $ path_parts );
127+
128+ $ request_path = $ url_parts ['scheme ' ] . ':// ' . $ url_parts ['host ' ];
129+ if (isset ($ url_parts ['port ' ])) {
130+ $ request_path .= ': ' . $ url_parts ['port ' ];
131+ }
132+ $ request_path .= $ new_path ;
133+ }
134+
135+ $ this ->uri = rtrim ($ request_path , '/ ' ) . '/soap/server.php?wsdl ' ;
107136 }
108137 }
109138 try {
0 commit comments