0

I am trying to consume a PHP Soap service however I seem to have having trouble with a complex/abstract type.

This is the SOAP call generated using SOAP UI :-

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:lin="http://llu.webservices.opalonline.co.uk/LineCharacteristicsWS">
   <soapenv:Header/>
   <soapenv:Body>
      <lin:GetLineCharacteristics>
         <lin:request>
            <!--Optional:-->
            <lin:UserCredentials>
               <!--Optional:-->

               <!--Optional:-->
               <lin:Username>testUser</lin:Username>
               <lin:Password>testPass</lin:Password><lin:AgentID>1234</lin:AgentID>
            </lin:UserCredentials>
            <lin:RequestDetails xsi:type="lin:TelephoneNumberRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <lin:TelephoneNumber>123456789</lin:TelephoneNumber>
            </lin:RequestDetails>
            <lin:UserConsent>Yes</lin:UserConsent>
            <lin:ServiceType>MPF</lin:ServiceType>
         </lin:request>
      </lin:GetLineCharacteristics>
   </soapenv:Body>
</soapenv:Envelope>

Here is my PHP code :-

$call = new StdClass();

$call->request =  new StdClass();
$call->request->UserConsent = "Yes";
$call->request->ServiceType = "MPF";

$call->request->UserCredentials =  new StdClass();
$call->request->UserCredentials->Username="testUser";
$call->request->UserCredentials->Password="testPass";
$call->request->UserCredentials->AgentID=1234;


$call->request->RequestDetails = new StdClass();
$call->request->RequestDetails->TelephoneNumber = "123456789";

$url = "https://llu.webservices.opalonline.co.uk/LineCharacteristicsWSV6/LineCharacteristicsWS.asmx?wsdl";
$client = new SoapClient($url, array('trace' => 1, exceptions=> 1,'soap_version' => SOAP_1_1));

$result = $client->GetLineCharacteristics($call);

echo $client->__getLastRequest();
echo $client->__getLastResponse();

When I run the code, the following error is generated :-

Fatal error: Uncaught SoapFault exception: [soap:Client] Server was unable to read request. ---> There is an error in XML document (2, 382). ---> The specified type is abstract: name='RequestType', namespace='http://llu.webservices.opalonline.co.uk/LineCharacteristicsWS', at http://llu.webservices.opalonline.co.uk/LineCharacteristicsWS'>. in /Users/jamesormerod/NetBeansProjects/fpdfDev/TestClass.php:23

Can anyone help?

2
  • try $request->TelephoneNumberRequest->TelephoneNumber Commented Mar 8, 2014 at 15:15
  • No, I believe it requires some kind of class map? Commented Mar 8, 2014 at 19:39

1 Answer 1

1

To be able to send the request well formed with correct type and namespace, you must use both classes named as the required elements and a classmap that maps the elements to the classes. The WsdlToPhp project can help you generate the classes and the classmap. You can use the project at wsdltophp.com.

Then if for example you generate the package with the name LineCharacteristics, you'll be able to send the request using this sample code:

$lineCharacteristicsServiceGet = new LineCharacteristicsServiceGet(); // sample call for LineCharacteristicsServiceGet::GetLineCharacteristics() $details = new LineCharacteristicsStructTelephoneNumberRequest('+3363136363636'); $request = new LineCharacteristicsStructGetLineCharacteristicsRequest($details, LineCharacteristicsEnumUserConsentEnum::VALUE_YES, LineCharacteristicsEnumServiceTypeEnum::VALUE_MPF); $userCredentials = new LineCharacteristicsStructCredentials(11111,'********','********'); $request->setUserCredentials($userCredentials); $characteristics = new LineCharacteristicsStructGetLineCharacteristics($request); $r = $lineCharacteristicsServiceGet->GetLineCharacteristics($characteristics); echo implode("\r\n", array($lineCharacteristicsServiceGet->getLastRequestHeaders(),$lineCharacteristicsServiceGet->getLastRequest(),$lineCharacteristicsServiceGet->getLastResponseHeaders(),$lineCharacteristicsServiceGet->getLastResponse())); if($r) print_r($lineCharacteristicsServiceGet->getResult()); else print_r($lineCharacteristicsServiceGet->getLastError());

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.