2

Unfortunately I have never worked with SOAP before, so I hope I can express myself well anyways.

I have the following SOAP request (it's for creating tickets in HPSM):

        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://schemas.hp.com/SM/7" xmlns:com="http://schemas.hp.com/SM/7/Common" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:SubmitIntApiIncidentRequest attachmentInfo="?" attachmentData="?" ignoreEmptyElements="true" updateconstraint="-1">
         <ns:model query="?">
            <ns:keys query="?" updatecounter="?">
               <!--Optional:-->
               <ns:id type="Decimal" mandatory="?" readonly="?">?</ns:id>
            </ns:keys>
            <ns:instance query="?" uniquequery="?" recordid="?" updatecounter="?">
               <!--Optional:-->
               <ns:registrationId type="String" mandatory="?" readonly="0">HPSM Registration ID</ns:registrationId>
               <!--Optional:-->
               <ns:contactId type="String" mandatory="?" readonly="?">???</ns:contactId>
               <!--Optional:-->
               <ns:affectedUserId type="String" mandatory="?" readonly="?">User ID</ns:affectedUserId>
               <!--Optional:-->
               <ns:serviceId type="String" mandatory="?" readonly="?">?</ns:serviceId>
               <!--Optional:-->
               <ns:affectedCiId type="String" mandatory="?" readonly="?">?</ns:affectedCiId>
               <!--Optional:-->
               <ns:priority type="String" mandatory="?" readonly="?">?</ns:priority>
               <!--Optional:-->
               <ns:title type="String" mandatory="?" readonly="?">?</ns:title>
               <!--Optional:-->
               <ns:description type="String" mandatory="?" readonly="?">description</ns:description>
               <!--Optional:-->
               <ns:returnCode type="String" mandatory="?" readonly="?">?</ns:returnCode>
               <!--Optional:-->
               <ns:returnMessage type="String" mandatory="?" readonly="?">?</ns:returnMessage>
               <!--Optional:-->
               <ns:returnTicketId type="String" mandatory="?" readonly="?">?</ns:returnTicketId>
               <!--Optional:-->
               <ns:submittedBy type="String" mandatory="?" readonly="?">?</ns:submittedBy>
               <!--Optional:-->
               <ns:submitterGroup type="String" mandatory="?" readonly="?">?</ns:submitterGroup>
               <!--Optional:-->
               <ns:assignmentGroup type="String" mandatory="?" readonly="?">?</ns:assignmentGroup>
               <!--Optional:-->
               <ns:externalReferenceId type="String" mandatory="?" readonly="?">?</ns:externalReferenceId>
               <!--Optional:-->
               <ns:category type="String" mandatory="?" readonly="?">?</ns:category>
               <!--Optional:-->
               <ns:resolveImmediately type="Boolean" mandatory="?" readonly="?">?</ns:resolveImmediately>
               <!--Optional:-->
               <ns:solutionCode type="String" mandatory="?" readonly="?">?</ns:solutionCode>
               <!--Optional:-->
               <ns:solution type="String" mandatory="?" readonly="?">?</ns:solution>
               <!--Optional:-->
               <ns:contactInfo type="String" mandatory="?" readonly="?">?</ns:contactInfo>
               <!--Optional:-->
               <ns:incidentType type="String" mandatory="?" readonly="?">?</ns:incidentType>
               <!--Optional:-->
               <ns:attachments>
                  <!--Zero or more repetitions:-->
                  <com:attachment xm:contentType="application/?" href="?" contentId="?" action="?" name="?" type="?" len="?" charset="?" upload.by="?" upload.date="?" attachmentType="?">cid:933455187673</com:attachment>
               </ns:attachments>
            </ns:instance>
            <!--Optional:-->
            <ns:messages>
               <!--Zero or more repetitions:-->
               <com:message type="String" mandatory="?" readonly="?" severity="?" module="?">?</com:message>
            </ns:messages>
         </ns:model>
      </ns:SubmitIntApiIncidentRequest>
   </soapenv:Body>
</soapenv:Envelope>

By now I have the following code in my soapcall.php file:

    <?php         

    $wsdl ='asdf?wsdl';
    $client = new SoapClient($wsdl, array('login' => "user", 'password' => "pw"));


    $request = array(
        'SubmitIntApiIncident'=>(array(
            'model' => '',
            'registrationID' => 'registrationid',
            'contactId' => 'me',
            'affectedUserId' => 'affuser',
            'serviceId' => 'serviceid',
            'affectedCiId' => '',
            'priority' => '4',
            'title' => 'Test Title',
            'description' => 'description',
            'submittedBy' => 'me',
            'assignmentGroup' => 'assignment group',
            'externalReferenceId' => '',
            'category' => 'incident',
            'resolveImmediately' => ''
        )));

    $response = $client->__soapCall("SubmitIntApiIncident", $request);
    var_dump($response);


?>

This does not work at all - right now I don't get any error message, there is just a blank page. But every time I change something in the code there is another error message. So I don't even know if I am on the right track or if everything I try just makes it worse.

I would really appreciate if you could tell me if there is any big error in my code or how I could successfully submit a ticket with the php file.

Tim Kühn
  • 47
  • 1
  • 1
  • 12
  • Maybe you can find some info here: http://stackoverflow.com/questions/3572414/how-do-i-see-the-actual-xml-generated-by-php-soap-client-class – junkfoodjunkie Apr 12 '17 at 12:23
  • Thank you, but unfortunately I could not find out any solution yet. – Tim Kühn Apr 12 '17 at 13:21
  • add `error_reporting(E_ALL|E_NOTICE);` at the head of the PHP code to see all errors and warnings. – Adder Apr 12 '17 at 13:43
  • Thank you for this, unfortunately the page is still empty. – Tim Kühn Apr 12 '17 at 13:54
  • I think I just figured out a little more: I always tried it with the "__soapCall" function, but I think the "__doRequest" function is the one I need, as I am trying to send data from the php file to the SOAP API, not vice versa. But whatever I try to submit with the doRequest function, nothing works. – Tim Kühn Apr 12 '17 at 14:05

1 Answers1

1

Using the __soapCall method is one of the good way. You can also directly use the operation name as the method such as $client->SubmitIntApiIncident().

You should definitively use a WSDL to php generator in order to avoid wasting your time searching for the issue.

The advantage of using a WSDL to php generator are numerous :

  • construct the request without wondering how to construct it, just use a good IDE to have the autocompletion showing you what data to pass
  • send the request using the method of a generated class that handles cleanly errors and response
  • get the response with clean objects
  • get help from the generated classe to target the error
  • stop wondering if the request is well formatted
  • ...

Try the PackageGenerator project

Mikaël DELSOL
  • 760
  • 5
  • 15