Search code examples
web-servicessoapuinusoap

NuSoap PHP One value coming in as not null


This is a very unique question. So I am using NuSoap to communicate with a Soap Service. Everything is working fine. I am getting no errors, but here is where it gets weird. The Service is submitting correctly through Soap UI but not my code :(

There is one XML field that is:

<xs:element name="NameX" default="Yes" type="ns0:NameXType" minOccurs="0"/>

Here is the definition in the WSDL

<xs:simpleType name="NameXType">
  <xs:restriction base="xs:string">
    <xs:enumeration value=""/>
    <xs:enumeration value="Yes"/>
  </xs:restriction>
</xs:simpleType>

I assume that the above XML means that it can take a value of "Yes" or "" (nothing/null).

Now in my code I am doing this:

$result = $client->call('functionName', 
          array(
            'API_Status' => 'None',
              'AuthenticationInfo' => array(
                'userName' => $username,
                'password' => $password
              ),
            'Category' => 'Application',

            <!-- Problem Here -->
            'NameX' => null,
            <!-- Problem Here -->

            'Customer_DB_ID' => 'XXX',
            'Details' => 'External User Web Request',
            'Group' => 'NHLBI-CBI-WEB_Support',
            'Impact' => '4-Minor/Localize',
            'Item' => $classify,
            'Record_Type' => 'Support Request',
            'Short_Description' => $subject,
            'Status' => 'New',
            'Type' => 'Website',
            'Urgency' => '3-Medium',
            'Work_Log' => $message,
          ), $namespace = 'urn:Service', $soapAction = 'localhost/soapAction', $style = 'document', $use = 'literal' );

So that being said, the problem is that in all my submissions from the form I am developing, this NameX field keeps coming in as the default answer "Yes." I am officially saying I am lost and do not know how to proceed.

Now whats weird is, this NameX field is a Test field. If it is Yes only admins of the application can see the submission. If it is null, then it is available for all users to see.

What sucks is I am being blamed for this mess. I am not sure what to do next.

Here is how the output of a successful submission with NameX field as "" should look.:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Service">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:Create>
         <urn:AuthenticationInfo>
            <urn:userName>username</urn:userName>
            <urn:password>password</urn:password>
         </urn:AuthenticationInfo>
         <urn:Category>Application</urn:Category>
         <!--Optional:-->
         <urn:Customer_ID>12345</urn:Customer_ID>
         <urn:Details>Test</urn:Details>
         <urn:Group>Support</urn:Group>
         <urn:Impact>None</urn:Impact>
         <urn:Item>Test</urn:Item>
         <urn:Record_Type>Support Request</urn:Record_Type>
         <urn:Short_Description>Testing the short description</urn:Short_Description>
         <urn:Status>New</urn:Status>

         <!--THis is the field giving me issues:-->
         <ns0:NameX/>
         <!--THis is the field giving me issues:-->

         <urn:Type>Website</urn:Type>
         <urn:Urgency>3-Medium</urn:Urgency>
         <urn:Work_Log>Test work notes...Hello Testing...New</urn:Work_Log>
      </urn:Create>
   </soapenv:Body>
</soapenv:Envelope>

Any help is appreciated. Thanks! I hope I did not leave anything out. If you need some more code I can get it to you.


Solution

  • So I figured out the fix!!!!!

    Instead of calling from URL, I saved the wsdl locally and removed the field that was giving me issues. Now the application is working!!

    I know it was a weird question, but I thought I would give it a try..