0

这是我的PHP:

    $url = "http://localhost:3000/api/wsdl";

    $client = new SoapClient($url);

    $params->a  = 'a Value';
    $params->b  = 'another Value';

    $client->AnOperation($params);

这是一个使用我用来创建我的肥皂服务器的wash_out gem 的红宝石控制器:

require "wash_out/soap"

class ApiController < ApplicationController
  soap_service namespace: 'urn:WashOut'

  soap_action "AnOperation",
              :args   => { :a => :string, :b => :string },
              :return => :string
  def AnOperation
    render :soap => "done"
  end

  before_filter :dump_parameters
  def dump_parameters
    logger.debug params.inspect
  end
end

这是生成的 WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:WashOut" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 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/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="api" targetNamespace="urn:WashOut">
  <types>
    <schema targetNamespace="urn:WashOut" xmlns="http://www.w3.org/2001/XMLSchema">
    </schema>
  </types>
  <portType name="api_port">
    <operation name="AnOperation">
      <input message="tns:AnOperation"/>
      <output message="tns:AnOperation_response"/>
    </operation>
  </portType>
  <binding name="api_binding" type="tns:api_port">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="AnOperation">
      <soap:operation soapAction="AnOperation"/>
      <input>
        <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WashOut"/>
      </input>
      <output>
        <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WashOut"/>
      </output>
    </operation>
  </binding>
  <service name="service">
    <port name="api_port" binding="tns:api_binding">
      <soap:address location="http://localhost:3000/api/action"/>
    </port>
  </service>
  <message name="AnOperation">
    <part name="a" type="xsd:string"/>
    <part name="b" type="xsd:string"/>
  </message>
  <message name="AnOperation_response">
    <part name="value" type="xsd:string"/>
  </message>
</definitions>

当我运行 PHP 时,我得到“stdClass 类的对象无法转换为字符串”。

4

1 回答 1

0

This appears to be two things:

1) My WSDL cache was on for PHP. It was caching an old version of the WSDL that I was developing in ruby. You can shut the cache off at the runtime level, or at the configuration level.

2) My object structure for the request was off. I was submitting the parameters via an object with key/value pairs, but this was not being expected in the WSDL. I adjusted my message for the operation in the WSDL to take a "part" that contains the parameters I'm passing.

于 2013-10-17T23:02:32.497 回答