PHP SOAP 请求不正确



我尝试构建以下 SOAP 请求:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CheckSomething xmlns="http://service.mydomain.com/">
      <User>
        <username>user123</username>
        <password>geheim</password>
      </User>
      <ItemXY>something</ItemXY>
    </CheckSomething>
  </soap:Body>
</soap:Envelope>

这是我的PHP代码

$soapClient = new SoapClient("http://service.mydomain.com/Services.asmx?wsdl",array( "trace" => 1 ));
$Param = array (
  'username' => "user123",
  'password' => "geheim"
);
$info = $soapClient->__call("CheckSomething", array("User" => $Param,"ItemXY" => "something"));
echo "Request :n".htmlspecialchars($soapClient->__getLastRequest()) ."n";

结果是:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://service.mydomain.com/">
<SOAP-ENV:Body>
<ns1:CheckSomething/>
<param1>something</param1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这是此服务的 wsdl 部分:

<s:element name="CheckSomething">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="User" type="tns:Validation"/>
      <s:element minOccurs="0" maxOccurs="1" name="ItemXY" type="s:string"/>
    </s:sequence>
  </s:complexType>
</s:element>

谁能帮我形成正确的SOAP请求?

如何删除结果标签中的ns1,并提供正确的数组用户和 ItemXY?

在我将 PHP 代码修改为:

$soapClient = new SoapClient("http://service.mydomain.com/Services.asmx?wsdl",array( "trace" => 1 ));
$user_param = array (
  'username' => "user123",
  'password' => "geheim"
);
$service_param = array (
  'User' => $user_param,
  "ItemXY" => "something"
);
$info = $soapClient->__call("CheckSomething", array($service_param));
echo "Request :n".htmlspecialchars($soapClient->__getLastRequest()) ."n";

它有效!

最新更新