Ruby スクリプトを使用して PHP ページから Web サービスを呼び出そうとしています。PHP スクリプトは文字列を返し、それ自体が別の Web サービスを呼び出します。PHP スクリプトだけをテストしたところ、1 つの文字列が返されました。次のコードを使用して、RPC 経由でこのメソッドを呼び出そうとしています。
require 'soap/rpc/driver'
driver = SOAP::RPC:Driver.new('http://mysite.com/services/webservices.php', 'urn:mysite')
driver.add_method('getMobileCarrier', 'phoneNumber')
driver.getMobileCarrier('15551234567') # fake number, obviously
私はこの結果を返します:
REXML::ParseException: malformed XML: missing tag start
Line:
Position:
Last 80 unconsumed characters:
< in <b>/var/www/html/services/webservices.php</b>
from /opt/local/lib/ruby/1.8/rexml/parsers/baseparser.rb:356:in `pull'
from /opt/local/lib/ruby/1.8/rexml/parsers/streamparser.rb:16:in `parse'
from /opt/local/lib/ruby/1.8/rexml/document.rb:201:in `parse_stream'
from /opt/local/lib/ruby/1.8/xsd/xmlparser/rexmlparser.rb:27:in `do_parse'
from /opt/local/lib/ruby/1.8/soap/parser.rb:92:in `parse'
from /opt/local/lib/ruby/1.8/soap/processor.rb:39:in `unmarshal'
from /opt/local/lib/ruby/1.8/soap/rpc/proxy.rb:236:in `unmarshal'
from /opt/local/lib/ruby/1.8/soap/rpc/proxy.rb:175:in `route'
from /opt/local/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
from /opt/local/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
from /opt/local/lib/ruby/1.8/soap/rpc/driver.rb:232:in `getMobileCarrier'
from (irb):4
ただし、PHPコード自体を実行すると(そして明らかに実際の値を指定すると)、エラーはまったくスローされず、期待値が返されます。Ruby と REXML では機能しません。どうすればこれを修正できますか? PHP スクリプトが呼び出している Web サービスはサードパーティによるものであり、応答を変更することはできませんが、明らかに応答は PHP で正常に機能していますが、REXML には問題があります。