3

i try to build following SOAP Request:

<?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>

Here is my PHP Code

$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";

The result is:

<?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>

This is the wsdl section for this Service:

<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>

Can anybody help me to form the right SOAP request?

How to remove the ns1 in the result Tag an give the correct Array User and ItemXY?

hakre
  • 193,403
  • 52
  • 435
  • 836
kockiren
  • 711
  • 1
  • 12
  • 33

1 Answers1

7

After i modify the PHP Code to:

$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";

it works!

kockiren
  • 711
  • 1
  • 12
  • 33
  • thanks for this response. for readers: sometimes just wrap your array of arguments into array is enough. – OZ_ Aug 20 '15 at 19:42