I am trying to write a client in php to talk to a webservice by sending 4 strings as a complex type and then supposed
to return an array with 2 elements for each brand in the array (code, name).Using latest ver. of php with nusoap lib.
Below is copy of the wsdl.
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.mycompany.com/soap"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.mycompany.com/soap">
<types>
<xsd:schema targetNamespace="http://www.mycompany.com/soap">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="brandlistReqData">
<xsd:all>
<xsd:element name="xmlUser" type="xsd:string"/>
<xsd:element name="xmlPassword" type="xsd:string"/>
<xsd:element name="serviceName" type="xsd:string"/>
<xsd:element name="serviceMode" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="brands">
<xsd:all>
<xsd:element name="code" type="xsd:string"/>
<xsd:element name="name" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="BrandsArray">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:Brands[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="BrandReturn">
<xsd:all>
<xsd:element name="errorCode" type="xsd:int"/>
<xsd:element name="errorMessage" type="xsd:string"/>
<xsd:element name="brandlist" type="tns:BrandsArray"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<message name="getbrandlistRequest">
<part name="datasent" type="tns:brandlistReqData"/>
</message>
<message name="getbrandlistResponse">
<part name="return" type="tns:BrandReturn"/>
</message>
<portType name="GetbrandlistwsdlPortType">
<operation name="getbrandlist">
<input message="tns:getbrandlistRequest"/>
<output message="tns:getbrandlistResponse"/>
</operation>
</portType>
<binding name="GetbrandlistwsdlBinding" type="tns:GetbrandlistwsdlPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getbrandlist">
<soap:operation soapAction="urn:Getbrandlistwsdl" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:Getbrandlistwsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:Getbrandlistwsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="getBrandList">
<documentation>Return 3 character code and name of brands</documentation>
<port name="GetbrandlistwsdlPort" binding="tns:GetbrandlistwsdlBinding">
<soap:address
location="https://www.mycompany.com/wwiz.asp?wwizmstr=XML.WEB.SERVICES"/>
</port>
</service>
</definitions>
|
I am unsure if the WSDL is correct , but I was able to use SOAPUI 1.7.6 , a java app,
to connect , input the data for the 4 strings and then get a successful return.
All I get when I try the php client is an error
HTTP Error: Unsupported HTTP response status 405 Method not allowed (soapclient->response has contents of the response)
|
client
<?php
require_once('./lib/nusoap.php');
$client = new nusoap_client("http://www.mycompany.com/soap", false);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
//below are the definitions
$brandlistReqData = array(
'xmlUser' => '1',
'xmlPassword' => '2',
'serviceName' => '3',
'serviceMode' => '4'
);
$params = array('datasent' =>
new soapval('datasent',
'getbrandlist',
$brandlistReqData,
false,
'http://mycompany.com/soap')
);
$result = $client->call('getbrandlist', $params, 'datasent','urn:Getbrandlistwsdl', 'this_is_header_env');
if ($client->fault) {
echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
}
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
?>
|
I was actually trying to do this with excel, but couldn't be done.
Very new to this.
can anyone help point me in the right direction as to the structure of correct code for the client.
Thank You