Link to home
Start Free TrialLog in
Avatar of Eddie Shipman
Eddie ShipmanFlag for United States of America

asked on

PHP SOAP server

I'm trying to build a server for another soap server to call and give back a soap response in PHP and NuSoap.

The soap service that will be sending the request is here https://supplieruatsp.testpartstrader.us.com/v2.0/services/InventoryOptionsService.svc
Now, this service will send me a request that I'm supposed to parse, then query some data and send back a response.

I have built a simple server and client for testing but I'm getting nowhere, nothing but errors from NuSoap. I am also seeing this as an error:
wsdl error: Bad path to WSDL file ://IBMSSimpleTypes.xsd

I cannot find IBMSSimpleTypes in any file on my local web server.

Not sure what the problem is as I have never written this in PHP before.

Can anyone help out here?


Server:
<?php
require_once "./lib/nusoap.php";

$server = new soap_server('InventoryOptionsService.wsdl'); // contains a local copy of the wsdl from the service

$server->service(file_get_contents("php://input"));

    function SubmitInventory($request) {
        echo $request;
        exit;
}        

Open in new window


Client
<?php
require_once "./lib/nusoap.php";
$client = new nusoap_client("InventoryOptionsService.wsdl", true);

$error = $client->getError();
if ($error) {
    echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}
$request = file_get_contents("RequestExample.xml");

$result = $client->call("SubmitInventory", $request);

if ($client->fault) {
    echo "<h2>Fault</h2><pre>";
    print_r($result);
    echo "</pre>";
}
else {
    $error = $client->getError();
    if ($error) {
        echo "<h2>Error</h2><pre>" . $error . "</pre>";
    }
    else {
        echo "<pre>";
        echo $result;
        echo "</pre>";
    }
}

echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Does this file exist and is it in the same folder as the server script?
InventoryOptionsService.wsdl

Open in new window

Same for client.
Avatar of Eddie Shipman

ASKER

Yes to both, all in same folder
I actually downloaded all the XSD files into that directory, too
Can you post it so we can test.

Also confirm you have the latest NuSoap library from here (https://sourceforge.net/projects/nusoap/)

What version of PHP are you on

Need the above to replicate issue.
I have downloaded latest NuSoap, PHP version is 5.6.31.
I'm sorry but I cannot post to public because I don't have access, yet. I'm developing locally on WAMP and then testing on LAMP in VirtualBox before deployment.

What's funny is it says it can't find file://IBMSSimpleTypes.xsd

I did download a file named BMSSimpleTypes.xsd...
I meant can you post the wsdl file - the one that defines your SOAP interfaces.
It is essentially the one you would get by visiting the service URI:
https://supplieruatsp.testpartstrader.us.com/v2.0/services/InventoryOptionsService.svc?wsdl

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" 
  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
  xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 
  xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" 
  xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" 
  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
  xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
  xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:tns="http://tempuri.org/" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
  name="InventoryOptionsService" 
  targetNamespace="http://tempuri.org/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://tempuri.org/Imports">      
        <xsd:import id="methodSchema" schemaLocation="InventoryOptionsServiceXsd0.xsd"  namespace="http://tempuri.org/"/>
        <xsd:import id="dataSchema" schemaLocation="BMSProcurementMessages.xsd"  namespace="http://www.cieca.com/BMS"/>
        <xsd:import id="procurementCommonTypes" schemaLocation="BMSProcurementCommonTypes.xsd"  namespace="http://www.cieca.com/BMS"/>
        <xsd:import id="commonGlobalTypes" schemaLocation="BMSCommonGlobalTypes.xsd"  namespace="http://www.cieca.com/BMS"/>
        <xsd:import id="classicCodeLists" schemaLocation="BMSClassicCodeLists.xsd"  namespace="http://www.cieca.com/BMS"/>
        <xsd:import id="simpleTypes" schemaLocation="BMSSimpleTypes.xsd"  namespace="http://www.cieca.com/BMS"/>
    </xsd:schema>
  </wsdl:types>
  
  <wsdl:message name="InventoryOptionsService_SubmitInventory_InputMessage">
    <wsdl:part name="parameters" element="tns:SubmitInventory"/>
  </wsdl:message>
  
  <wsdl:message name="InventoryOptionsService_SubmitInventory_OutputMessage">
    <wsdl:part name="parameters" element="tns:SubmitInventoryResponse"/>
  </wsdl:message>
  
  <wsdl:portType name="InventoryOptionsService">
    <wsdl:operation name="SubmitInventory">
      <wsdl:input wsaw:Action="http://tempuri.org/InventoryOptionsService/SubmitInventory" message="tns:InventoryOptionsService_SubmitInventory_InputMessage"/>
      <wsdl:output wsaw:Action="http://tempuri.org/InventoryOptionsService/SubmitInventoryResponse" message="tns:InventoryOptionsService_SubmitInventory_OutputMessage"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="BasicHttpBinding_InventoryOptionsService" type="tns:InventoryOptionsService">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="SubmitInventory">
        <soap:operation soapAction="http://tempuri.org/InventoryOptionsService/SubmitInventory" style="document"/>
        <wsdl:input>
          <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
          <soap:body use="literal"/>
        </wsdl:output>
      </wsdl:operation>
  </wsdl:binding>
  
  <wsdl:service name="InventoryOptionsService">
    <wsdl:port name="BasicHttpBinding_InventoryOptionsService" binding="tns:BasicHttpBinding_InventoryOptionsService">
	  <soap:address location="https://supplieruatsp.testpartstrader.us.com/v2.0/services/InventoryOptionsService.svc"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Open in new window

Julian, I'm going to close this question as I've decided to use the Zend SOAP extension due to Exception handling. do you have any experience with it?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial