2

I am trying to create SoapServer, theoretically looking at WSDL everything should be ok, however server I have implemented is returning not valid Response. Part of the wsdl which define request and response:

  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="testns">
      <s:element name="serviceRequest">
        <s:complexType>
                        <s:sequence>
                                <s:element name="id" form="unqualified" type="s:string" minOccurs="0" />
                                <s:element name="result" form="unqualified" minOccurs="0" maxOccurs="unbounded">
                                        <s:complexType>
                                                <s:sequence>
                                                        <s:element name="errorCode" form="unqualified" type="s:string" minOccurs="0" />
                                                        <s:element name="errorDescription" form="unqualified" type="s:string" minOccurs="0" />
                                                        <s:element name="nativeErrorCode" form="unqualified" type="s:string" minOccurs="0" />
                                                        <s:element name="nativeErrorDescription" form="unqualified" type="s:string" minOccurs="0" />
                                                </s:sequence>
                                        </s:complexType>
                                </s:element>
                        </s:sequence>
                </s:complexType>
      </s:element>
      <s:element name="serviceresponse">
        <s:complexType>
          <s:sequence>
                        <s:element name="result" form="unqualified" minOccurs="0" maxOccurs="unbounded">
                                        <s:complexType>
                                                <s:sequence>
                                                        <s:element name="errorCode" form="unqualified" type="s:string" minOccurs="0" />
                                                        <s:element name="errorDescription" form="unqualified" type="s:string" minOccurs="0" />
                                                        <s:element name="nativeErrorCode" form="unqualified" type="s:string" minOccurs="0" />
                                                        <s:element name="nativeErrorDescription" form="unqualified" type="s:string" minOccurs="0" />
                                                </s:sequence>
                                        </s:complexType>
                                </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>

and my function inside of php handler:

function handleService($serviceRequest){
 try{
  throw new Exception("test exception",3);
 }catch (Exception $e){
  return array(array("serviceResponse"=>array(
    "result"=>array(
        "errorCode"=>"1",
        "errorDescription"=>"Error detected",
        "nativeErrorCode"=>"".$e->getCode(),
        "nativeErrorDescription"=>"".$e->getMessage()
        )
  )));
 }
}

this result in send response which looks like this:

   <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="testns">
    <SOAP-ENV:Body>
    <ns1:serviceResponse>
    <result/>
    </ns1:serviceResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

The result tag is empty but array which is describing it inside my server should be set. Can anyone give me a hint what I am missing?

Mithrand1r
  • 2,313
  • 9
  • 37
  • 76
  • Where do you define `$e`? Should it be `$serviceRequest`? – scrowler Mar 26 '15 at 11:05
  • my apologise, I wanted to show as little code as possible so it will be easy to point where I am doing a mistake. I have edited my post $e is Exception which is thrown – Mithrand1r Mar 26 '15 at 11:11

0 Answers0