2016-08-26 10 views
0

私はSOAP経由でPHP(rpc)のメソッドを呼び出すJavaプログラムを持っています。 数日から、それは私の既存のコードから長い間働いていません。 私の開発マシンでは、私は最近php7.0に更新しましたが、リモートサーバー上ではまだphp5.xが動作しています。どちらもローカルホストでもリモートサーバでも動作しません。両方のマシンは、(遠隔14.04 DEV 16.04)PHP:JavaからSOAP rpc webserviceを呼び出す際にエラーが発生しました。

Ubuntuを使用している私はいつも次のエラーを取得:

[SOAPException: faultCode=SOAP-ENV:Client; msg=Parsing error, response was: 
The processing instruction target matching "[xX][mM][lL]" is not allowed.; targetException=org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 
The processing instruction target matching "[xX][mM][lL]" is not allowed.] 

私はSOAPのUIでテストを、そしてそれは、エラーが働きません。 私はapache axis2でテストしましたが、失敗しました。

問題は、PHPスクリプトからの応答が無効であるようです。

符号化などを見て、新しい行などがあるかどうかを確認しました。しかし、私は問題が何であるかという手がかりは持っていません。ソープUIで動作

サンプルSOAPコール:

<?xml version='1.0' encoding='UTF-8'?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<SOAP-ENV:Body> 
<ns1:searchQuery xmlns:ns1="http://localhost/Server.php" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
<query xsi:type="xsd:string">oil</query> 
</ns1:searchQuery> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

応答:私は石鹸UIで検証をクリックすると、それがXML declrationがうまく形成されていないことを私に伝えます。しかし、私はそれをどのように変更するか分かりません。

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/Server.php" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
<SOAP-ENV:Body><ns1:searchQueryResponse><return xsi:type="xsd:string">{ 
    "prefixes": ..... } 
</return></ns1:searchQueryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> 

私は石鹸サーバーを初期化するために使用するPHPコード:

try { 

    ini_set ("soap.wsdl_cache_enabled", "0"); 
    $server = new SOAPServer ('Server.wsdl'); 
    $server->setClass ('Webdienst'); 
    $server->handle(); 
} 

catch (SOAPFault $f) { 
    echo $f->getMessage(); 
} 

私のWSDLファイル:

<?xml version="1.0"?> 
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost/Server.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Webdienst" targetNamespace="http://localhost/Server.php"> 
    <types> 
    <xsd:schema targetNamespace="http://localhost/Server.php"> 
     <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </xsd:schema> 
    </types> 
    <portType name="WebdienstPort"> 
    <operation name="createRecord"> 
     <documentation>Create a new record</documentation> 
     <input message="tns:createRecordIn"/> 
     <output message="tns:createRecordOut"/> 
    </operation> 
    <operation name="searchQuery"> 
     <documentation>Search for the String</documentation> 
     <input message="tns:searchQueryIn"/> 
     <output message="tns:searchQueryOut"/> 
    </operation> 
    </portType> 
    <binding name="WebdienstBinding" type="tns:WebdienstPort"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="createRecord"> 
     <soap:operation soapAction="http://localhost/Server.php#createRecord"/> 
     <input> 
     <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/> 
     </input> 
     <output> 
     <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/> 
     </output> 
    </operation> 
    <operation name="searchQuery"> 
     <soap:operation soapAction="http://localhost/Server.php#searchQuery"/> 
     <input> 
     <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/> 
     </input> 
     <output> 
     <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/> 
     </output> 
    </operation> 
    </binding> 
    <service name="WebdienstService"> 
    <port name="WebdienstPort" binding="tns:WebdienstBinding"> 
     <soap:address location="http://localhost/Server.php"/> 
    </port> 
    </service> 
    <message name="createRecordIn"> 
    <part name="recordURI" type="xsd:anyType"/> 
    <part name="documentURI" type="xsd:anyType"/> 
    <part name="content" type="xsd:anyType"/> 
    <part name="fileName" type="xsd:anyType"/> 
    <part name="mimeType" type="xsd:anyType"/> 
    <part name="creationDate" type="xsd:anyType"/> 
    <part name="datasetURI" type="xsd:anyType"/> 
    <part name="translatedContent" type="xsd:anyType"/> 
    <part name="alchemyTopics" type="xsd:anyType"/> 
    <part name="summary" type="xsd:anyType"/> 
    <part name="author" type="xsd:anyType"/> 
    </message> 
    <message name="createRecordOut"> 
    <part name="return" type="xsd:string"/> 
    </message> 
    <message name="searchQueryIn"> 
    <part name="query" type="xsd:anyType"/> 
    </message> 
    <message name="searchQueryOut"> 
    <part name="return" type="xsd:string"/> 
    </message> 
</definitions> 

答えて

0

を私の周りグーグル後に解決策を見つけました。

問題は、別のPHPファイルを含むsoapサーバークラスの先頭にinclude()宣言があることでした。他のPHPファイルには、?>終了タグの後に空白行があります。私は最後のブレースの直後に終了タグを移動し、今は動作します!

関連する問題