WSDL SoapClient和PHP +拥有Namespace

时间:2012-09-14 09:31:27

标签: php soap namespaces wsdl request

我已经尝试了一段时间来获得SoapRequest,但我失败了:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
  <soap:Body xmlns:gog="http://www.test.nms">
    <gog:GenerateRequest>
      <gog:Application>TestApp</gog:Application>
      <gog:User>TestUser</gog:User>
      <gog: RequestCreateOnly>
        <gog:Count>1</gog:Count>
        <gog:Subject>Test</gog:Subject>
      </gog: RequestCreateOnly>
    </gog:GenerateRequest>
  </soap:Body>
</soap:Envelope>

我必须用PHP编写它。 问题是:

  

如何更改命名空间?   如何更改肥皂标签?   谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

我经常使用NuSOAP库来处理这类请求。我在下面提供了一段示例代码,对您有帮助吗?

require_once('path-to-nusoap/nusoap.php');

$client = new nusoap_client("http://www.mywebservicehere.com", 'wsdl');
$client -> setDefaultRpcParams(true);
$client -> useHTTPPersistentConnection();
$client -> soap_defencoding = 'UTF-8';
$client -> setUseCurl(true);

$request = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                <soap:Body xmlns:gog="http://www.test.nms">
                    <gog:GenerateRequest>
                        <gog:Application>TestApp</gog:Application>
                        <gog:User>TestUser</gog:User>
                        <gog: RequestCreateOnly>
                            <gog:Count>1</gog:Count>
                            <gog:Subject>Test</gog:Subject>
                        </gog: RequestCreateOnly>
                    </gog:GenerateRequest>
                </soap:Body>
            </soap:Envelope>';

$results = $client->send($request,'http://www.actionurlhere.com');