Quick license manager webservice doesn't accept request - php

I want to use the Quick License Manager SOAP webservice to connect an e-commerce wordpress plugin to enable the user to buy a license and show it after a successful purchase.So for now, I'm trying to call the function GetProductInfo to get the info of an existing product I created with the QLM Management Console.I use the SoapClient php class but when I try to make a request I get this response :
Error validating request: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. . Caller: GetProductInfo
I don't understand what's wrong with my request, so I need help...
Here is the code I use :
<?php
$url = "https://quicklicensemanager.com/****/qlm/qlmservice.asmx";
$wsdl = $url . "?WSDL";
$soapClient = new SoapClient($wsdl, array(
"encoding" => "utf8",
"trace" => TRUE,
"version" => SOAP_1_1
));
$req = sprintf(
'<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<QlmSoapHeader xmlns="http://www.interactive-studios.net/qlmweb">
<CultureName>%s</CultureName>
<UtcOffset>%d</UtcOffset>
</QlmSoapHeader>
</soap:Header>
<soap:Body>
<GetProductInfo xmlns="http://www.interactive-studios.net/qlmweb">
<eProductName>%s</eProductName>
<productID>%d</productID>
<major>%d</major>
<minor>%d</minor>
</GetProductInfo>
</soap:Body>
</soap:Envelope>', "en_US", 0, "The IO plug-in: Student License", 4, 1, 0);
echo '<pre>';
print_r(htmlentities($req));
echo '</pre>';
$action = "http://www.interactive-studios.net/qlmweb/GetProductInfo";
$res = $soapClient->__doRequest($req, $url, $action, 1);
echo '<pre>';
print_r($res);
echo '</pre>';
echo "=======================================================";
echo '<pre>';
print_r(htmlentities($soapClient->__getLastRequest()));
echo '</pre>';
echo "=======================================================";
echo '<pre>';
print_r($soapClient->__getLastRequestHeaders());
echo '</pre>';
Thanks in advance for your help.
EDIT
Now I tried to change the field productID and it appears that it is the one that was wrong. So it needs to be a base64 string, so I updated my code :
</soap:Envelope>', "en_US", 0, "The IO plug-in: Student License", 4, 1, 0); becomes </soap:Envelope>', "en_US", 0, base64_encode("The IO plug-in: Student License"), 4, 1, 0);
The new error message is :
Error validating request: Length of the data to decrypt is invalid.. Caller: GetProductInfo

After hours of searching, I found this in the documentation, at page 121 :
Note that all the methods exposed by the web service cannot be called with a URL except GetActivationKey
and ActivateKey. All other web methods implement a secure authentication mechanism that only accepts
requests from the QLM Console.
So, as I was trying to call GetProductInfo, it couldn't work outside the QLM Console.

Related

Dynamics NAV 2016 Web Service: Parameter * in method * in service * is null

I try to get a single contact from my Dynamics Nav Web Service (Dynamics Nav 2016). I do this with a SOAP-request in PHP.
The web service is a codeunit which contains two functions:
fGetContact(iContactNumber : Text[20]) oContact : Text[250]
IF rContact.GET(iContactNumber) THEN BEGIN
oContact := '';
oContact := rContact."No." + ';' +
rContact."Company Name" + ';' +
rContact."First Name" + ';' +
rContact.Surname + ';' +
rContact."E-Mail";
END;
EXIT(oContact);
fGetContacts() oContacts : Text[250]
IF rContact.GET('KT100190') THEN BEGIN
oContacts := '';
oContacts := rContact."No." + ';' +
rContact."Company Name" + ';' +
rContact."First Name" + ';' +
rContact.Surname + ';' +
rContact."E-Mail";
END;
EXIT(oContacts);
The second function, fGetContacts, works fine.
But when I call fGetContact with a contact number as parameter, it returns the following error:
Parameter iContactNumber in method FGetContact in service MyService is null!
I use the NTLMSoapClient like the following:
<?php
ini_set('soap.wsdl_cache_enabled', '0');
require_once 'ntlmstream.php';
require_once 'ntlmsoapclient.php';
$url = 'http://localhost:7047/DynamicsNAV90/WS/CRONUS/Codeunit/MyService';
$options = array(
'uri' => $url,
'location' => $url,
'trace' => true,
'login' => 'my_user',
'password' => 'my_password'
);
// we unregister the current HTTP wrapper
stream_wrapper_unregister('http');
// we register the new HTTP wrapper
stream_wrapper_register('http', 'MyServiceProviderNTLMStream') or die("Failed to register protocol");
// so now all request to a http page will be done by MyServiceProviderNTLMStream.
// ok now, let's request the wsdl file
// if everything works fine, you should see the content of the wsdl file
$client = new MyServiceNTLMSoapClient(null, $options);
// should display your reply
try {
$params = array('iContactNumber' => 'KT100190');
echo '<pre>';
echo $client->FGetContacts(); // works
echo $client->FGetContact($params); // doesn't work
echo '</pre>';
} catch (SoapFault $e) {
echo '<pre>';
var_dump($e);
echo '</pre>';
}
// restore the original http protocole
stream_wrapper_restore('http');
I also tried to call the function like this:
echo $client->FGetContact('KT100190');
The return error is the same as before.
I tested my function with SoapUI and the return value is exactly what it shuold be.
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="urn:microsoft-dynamics-schemas/codeunit/MyService">
<soapenv:Header/>
<soapenv:Body>
<new:FGetContact>
<new:iContactNumber>KT100190</new:iContactNumber>
</new:FGetContact>
</soapenv:Body>
</soapenv:Envelope>
Response:
<Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/soap/envelope/">
<Soap:Body>
<FGetContact_Result xmlns="urn:microsoft-dynamics-schemas/codeunit/MyService">
<return_value>KT100190;Add-ON Marketing;Chris;McGurk;chris.mcgurk#cronuscorp.net</return_value>
</FGetContact_Result>
</Soap:Body>
</Soap:Envelope>
So what am I doing wrong that this error appears and how can I fix it?
For what it's worth, I had this issue and solved it by adding "cache_wsdl" => WSDL_CACHE_NONE to the soap client's options.
Some fields were missing because of a cache issue after updating the WSDL.
I made a workaround and it works for me now.
I changed the $request variable in the class NTLMSoapClient, because the soap envelope that php sent to my service was absolutely useless.
So basically I just did this before the curl actions:
$request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="urn:microsoft-dynamics-schemas/codeunit/MyService">
<soapenv:Header/>
<soapenv:Body>
<new:FGetContact>
<new:iContactNumber>'.$this->iContactNumber.'</new:iContactNumber>
</new:FGetContact>
</soapenv:Body>
</soapenv:Envelope>';
(If someone have the same problem, try var_dump($request) and view source in browser. You will see what a mess PHP did there...)

I am trying to use amazon api code in php but it is giving me error of not supported version following is my code

following is the code which i am using with php to get xml response with amazon api service but it is giving me error stated as below of code.
<?php
// Your AWS Access Key ID, as taken from the AWS Your Account page
$aws_access_key_id = "A*********A";
// Your AWS Secret Key corresponding to the above ID, as taken from the AWS Your Account page
$aws_secret_key = "ue*******s+";
// The region you are interested in
$endpoint = "webservices.amazon.in";
$uri = "/onca/xml";
$params = array(
"Service" => "AWSECommerceService",
"Operation" => "ItemSearch",
"AWSAccessKeyId" => "AKIAJYSYWXDOF5CWIK5A",
"AssociateTag" => "unity0f-21",
"SearchIndex" => "All",
"Keywords" => "iphone",
"ResponseGroup" => "Images,ItemAttributes,Offers"
);
// Set current timestamp if not set
if (!isset($params["Timestamp"])) {
$params["Timestamp"] = gmdate('Y-m-d\TH:i:s\Z');
}
// Sort the parameters by key
ksort($params);
$pairs = array();
foreach ($params as $key => $value) {
array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
}
// Generate the canonical query
$canonical_query_string = join("&", $pairs);
// Generate the string to be signed
$string_to_sign = "GET\n".$endpoint."\n".$uri."\n".$canonical_query_string;
// Generate the signature required by the Product Advertising API
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $aws_secret_key, true));
// Generate the signed URL
$request_url = 'http://'.$endpoint.$uri.'?'.$canonical_query_string.'&Signature='.rawurlencode($signature);
echo "Signed URL: \"".$request_url."\"";
?>
it is giving error as unsupported version i tried everything but still error is occurring please help
response of the request for the xml file is as following:
<?xml version="1.0"?>
<ItemSearchErrorResponse
xmlns="http://ecs.amazonaws.com/doc/2005-10-05/">
<Error>
<Code>UnsupportedVersion</Code>
<Message>Version 2005-10-05 is unsupported. Please use 2011-08-01 or greater instead.</Message>
</Error>
<RequestId>9f95a47d-f593-4002-af01-85b1b12fdf2d</RequestId>
</ItemSearchErrorResponse>
Add a valid version to your $params array, e.g:
"ResponseGroup" => "Images,ItemAttributes,Offers",
"Version" => "2015-10-01"
I tested your script and found it works with the above.
The cause of the issue seems to be that the API defaults to a deprecated value if you omit the version parameter.

I'm getting Wrong Version While Sending a SOAP Request

I'm working on a flight booking API. I'm sending the data to the server in following way:
$location_URL = "http://59.162.33.102/ArzooWS/services/DOMFlightBooking?wsdl";
$action_URL ="http://booking.flight.arzoo.com";
$client = new SoapClient('http://59.162.33.102/ArzooWS/services/DOMFlightBooking?wsdl', array(
'soap_version' => SOAP_1_1,
'location' => $location_URL,
'uri' => $action_URL,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'trace' => 1,
));
I've also mentioned XML SOAP Body below edited parsed XML Formatted Request:
<?xml version="1.0" encoding="utf-8"?>
<Bookingrequest>
<onwardFlights>
<OriginDestinationOption>
<FareDetails>
<ChargeableFares>
<ActualBaseFare>5060</ActualBaseFare>
<Tax>4380</Tax>
<STax>32</STax>
<SCharge>0</SCharge>
<TDiscount>0</TDiscount>
<TPartnerCommission>0</TPartnerCommission>
</ChargeableFares>
<NonchargeableFares>
<TCharge>0</TCharge>
<TMarkup>300</TMarkup>
<TSdiscount>0</TSdiscount>
</NonchargeableFares>
</FareDetails>
<FlightSegments>
<FlightSegment>
<AirEquipType>321</AirEquipType>
<ArrivalAirportCode>DEL</ArrivalAirportCode>
<ArrivalDateTime>2013-10-20T08:00:00</ArrivalDateTime>
<DepartureAirportCode>BOM</DepartureAirportCode>
<DepartureDateTime>2013-10-20T06:00:00</DepartureDateTime>
<FlightNumber>6019</FlightNumber>
<OperatingAirlineCode>AI</OperatingAirlineCode>
<OperatingAirlineFlightNumber>6019</OperatingAirlineFlightNumber>
<RPH>
</RPH>
<StopQuantity>0</StopQuantity>
<airLineName>Air India</airLineName>
<airportTax>4380</airportTax>
<imageFileName>http://live.arzoo.com/FlightWS/image/AirIndia.gif</imageFileName>
<viaFlight>
</viaFlight>
<BookingClass>
<Availability>4</Availability>
<ResBookDesigCode>U</ResBookDesigCode>
</BookingClass>
<BookingClassFare>
<adultFare>5060</adultFare>
<bookingclass>U</bookingclass>
<classType>Economy</classType>
<farebasiscode>fjyS3YyUlEusLfJ4bwgPvQ==</farebasiscode>
<Rule>This fare is Refundable <br> Baggage : 25K<br>Booking Class : U|Re-Schedule Charges: Rs. 750 per sector + Fare difference (If any) +admin fee 500 + Service Fee of Rs. 250
Sector .|Cancellation Charges : Basic fare +Airline administration fee 500 + Service Charges 250 Per Passenger Per Sector .
|</Rule>
<adultCommission>0</adultCommission>
<childCommission>0</childCommission>
<commissionOnTCharge>0</commissionOnTCharge>
</BookingClassFare>
<Discount>0</Discount>
<airportTaxChild>0</airportTaxChild>
<airportTaxInfant>0</airportTaxInfant>
<adultTaxBreakup>2950,147,1283</adultTaxBreakup>
<childTaxBreakup>0,0,0</childTaxBreakup>
<infantTaxBreakup>0,0,0</infantTaxBreakup>
<octax>0</octax>
</FlightSegment>
</FlightSegments>
<id>arzoo11</id>
<key>wtZcSVMY/gphWFSOTFWg8nkII1434EZIGjnpJNQzayEK8sDjVS91GicTJzH+TWN+pNURIyTJYKOW
O8yH8+0tzpA4t8aEEvzaOE6ZnTtBotFDwLtSiN0xXiTOGgS0siJI1l7d9ata/3rxTgfh9d8ZSmFY
VI5MVaDyd5WrIWHlQL5zqWDbQb1E1IoDSY1wep73c6lg20G9RNQQnpVlWM7U0ZY7zIfz7S3O4J6m
G25LJItzqWDbQb1E1IoDSY1wep73c6lg20G9RNSKA0mNcHqe93OpYNtBvUTUpvdITjbFOR52+H1V
tJqs5kJfo6Sh44vDThgZv6ARhgviIKxphH+kbb9fDhZYRaCPm3lupCgitSmWO8yH8+0tzolfF9kG
WM+AaZ58PxEZgqCbbbGbXj1Z0D7dHS59eVX1JxMnMf5NY37ZbJ5llqmBpycTJzH+TWN+2WyeZZap
gacnEycx/k1jftlsnmWWqYGnJxMnMf5NY37ZbJ5llqmBpycTJzH+TWN+2WyeZZapgacnEycx/k1j
ftlsnmWWqYGnJxMnMf5NY36po4tljIBmEJgePqv2qP9fd/Usd8Uuz7FDwLtSiN0xXvtUK9az69O/
JxMnMf5NY37yK2PFSCI6AM2hLlYrFkYJQ8C7UojdMV7NoS5WKxZGCcr5VjCR04wgRviI6n9DzL3N
oS5WKxZGCUPAu1KI3TFezaEuVisWRglDwLtSiN0xXv4Xbn4sigRMv18OFlhFoI/cKcKe7FftvScT
JzH+TWN+2WyeZZapgacnEycx/k1jftlsnmWWqYGnJxMnMf5NY377Oxb/b44TR5Y7zIfz7S3O16CE
sDaAROm13h/OHWeGHw==</key>
</OriginDestinationOption>
</onwardFlights>
<returnFlights>
</returnFlights>
<personName>
<CustomerInfo>
<givenName>Rajnish</givenName>
<surName>Dubey</surName>
<nameReference>Mr.</nameReference>
<psgrtype>adt</psgrtype>
</CustomerInfo>
</personName>
<telePhone>
<phoneNumber>9595959595</phoneNumber>
</telePhone>
<email>
<emailAddress>rajnishdubey1988#gmail.com</emailAddress>
</email>
<creditcardno>5266474530046446</creditcardno>
<Clientid>7232326</Clientid>
<Clientpassword>*AB424E52FBBHDSFS74DFFSA7B747A9BAF61F8E</Clientpassword>
<partnerRefId>100200</partnerRefId>
<Clienttype>ArzooFWS1.1</Clienttype>
<AdultPax>1</AdultPax>
<ChildPax>0</ChildPax>
<InfantPax>0</InfantPax>
</Bookingrequest>
try
{
//$result = $client->getAvailability($dom->saveXML($request));
$result = $client->getBookingDetails($dom->saveXML($request));
$response= htmlentities($result);
echo "<h1> Client Response: </h1><pre>".htmlspecialchars($result, ENT_QUOTES)."</pre>";
}
catch(Exception $e){
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
Now when the data is being sent to the server I get an exception 'Wrong version'. I checked on the SERVER side, the log for this particular client isn't being hit at all. Means that the server didn't received the request. The same WSDL request format is created by AVAILABILITY API of the flight. I'm getting the available flight list by AVAILABILITY API. I converted the above code in XML, the API documentation has the same format as i'm sending the request. I checked on the internet but didn't find the solution for the same. Some says the version of SOAP i'm using is different but that's not the case. Because the Flight and Hotel Availability API Has same method of request and receiving the data from server.
Please help me. I'm stuck on this. Your help will be Appreciated.
this is working code of flight availibility by arzoo..
i also getting error while using SOAP CLIENT but when i use nusoap then they give me result..using this code if u get error like ip/password mismatch then You will call arzoo to verify your clientid and clientpassword
<?php
ini_set('max_execution_time','180');
include 'lib/nusoap.php';
$location_URL ='http://avail.flight.arzoo.com';
$action_URL ='http://demo.arzoo.com/ArzooWS/services/DOMFlightAvailability?wsdl';
$Request = '<Request>
<Origin>BOM</Origin>
<Destination>DEL</Destination>
<DepartDate>2017-02-02</DepartDate>
<ReturnDate>2017-02-02</ReturnDate>
<AdultPax>1</AdultPax>
<ChildPax>0</ChildPax>
<InfantPax>0</InfantPax>
<Currency>INR</Currency>
<Clientid>Given by Arzoo.com</Clientid>
<Clientpassword>Given by Arzoo.com</Clientpassword>
<Clienttype>ArzooFWS1.1</Clienttype>
<Preferredclass>E</Preferredclass>
<mode>ONE</mode>
<PreferredAirline>AI</PreferredAirline>
</Request>';
$clientinfo = array('soap_version'=>SOAP_1_1,
'location' =>$location_URL,
'uri' =>$action_URL,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'trace' => 1,
);
$client = new nusoap_client('http://demo.arzoo.com/ArzooWS/services/DOMFlightAvailability?wsdl', $clientinfo);
//print_r($client);
$result = $client->call('getAvailability', array($Request));
echo"<pre>";
print_r($result);
$clientInfo =simplexml_load_string(utf8_encode($result));
$flight = $clientInfo->Response__Depart->OriginDestinationOptions->OriginDestinationOption;
$error =$clientInfo->error__tag;
//echo $error;
var_dump($flight);
//exit;
//echo"<pre>";
//print_r($result);
//ECHO $error;
?>

SoapClient Returns "NULL", but __getLastResponse() returns XML

The variable $response in the below code is NULL even though it should be the value of the SOAP request. (a list of tides). When I call $client->__getLastResponse() I get the correct output from the SOAP service.
Anybody know what is wrong here? Thanks! :)
Here is my code :
$options = array(
"trace" => true,
"encoding" => "utf-8"
);
$client = new SoapClient("http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl", $options);
$params = array(
"stationId" => 8454000,
"beginDate" => "20060921 00:00",
"endDate" => "20060922 23:59",
"datum" => "MLLW",
"unit" => 0,
"timeZone" => 0
);
try {
$result = $client->getHLPredAndMetadata($params);
echo $client->__getLastResponse();
}
catch (Exception $e) {
$error_xml = $client->__getLastRequest();
echo $error_xml;
echo "\n\n".$e->getMessage();
}
var_dump($result);
The reason that the $result (or the response to the SoapCall) is null is indeed because the WSDL is invalid.
I just ran into the same problem - the WSDL said the response should be PackageChangeBatchResponse yet the actual XML returns has PackageChangeResponse
Changing the WSDL to match the response / changing the response to match the WSDL resolves the issue
you should give an option parameter as below :
<?php
// below $option=array('trace',1);
// correct one is below
$option=array('trace'=>1);
$client=new SoapClient('some.wsdl',$option);
try{
$client->aMethodAtRemote();
}catch(SoapFault $fault){
// <xmp> tag displays xml output in html
echo 'Request : <br/><xmp>',
$client->__getLastRequest(),
'</xmp><br/><br/> Error Message : <br/>',
$fault->getMessage();
}
?>
"trace" parameter enables the output of request. Now, you should see the SOAP request.
(source: PHP.net

Why cant php work with WCF 4.0 asp website with a WCF service work?

Ok my .net 4.0 client works fine. People using java all have no issues. But when it comes to php our php developer cant get anything to work.
Now keep in mind i did not create a Wcflibray project, i created a regular asp 4.0 website and then added a WCF Service so i do not have a app.config, i have a web.config.
We have went down to the bare essentials of creating two methods
string HelloWorld()
{
return "Hello!";
}
and
string HellowTomorrow(string sret)
{
return sret;
}
In debug mode i will see him enter my method but only with null. If i packet sniff with wireshark, he is not passing the paramater envelope.
I have googled endlessly but all examples are from a WCF service project, not a website that has added a WCF Service too it. (rememember, everyone else is having no problems, java, .net 2.0, etc)
Here is his php 5.3
error_reporting(E_ALL);
ini_set('display_errors','On');
$client = new SoapClient("http://99-mxl9461k9f:6062/DynamicWCFService.svc?wsdl", array('soap_version' => SOAP_1_1));
$client->soap_defencoding = 'UTF-8';
//$args = array('john');
$args = array('param1'=>'john');
$webService = $client->__soapCall('HelloTomorrow',$args);
//$webService = $client->HelloTomorrow($args);
var_dumpp($webService);
?>
While working with WCF service .net as Server and PHP-soap as client you need to follow guideline strictly. The documentation of PHP-soap is not enough to debug and not that clear either. PHP nusoap is little better on documentation but still not enough on example and not a great choice for the beginners. There are a few examples for nusoap but most of them don’t work.
I would suggest following debug checklist:
Check the binding in your web.config file. It has to be “basicHttpBinding” for PHP
PHP, $client->__soapCall() function sends all arguments as an array so if your web-service function require input parameters as an array then arguments has to be in an extra array. Example#3 is given below to clear.
If required then pass “array('soap_version' => SOAP_1_1)” or “array('soap_version' => SOAP_1_2)” to SoapClient() object to explicitly declare soap version.
Always try declaring “array( "trace" => 1 )” to SoapClient Object to read the Request & Response strings.
Use “__getLastResponse();” function to read Response String.
Use “__getLastRequest();” function to read Request String.
IMPORTANT:If you are getting NULL return for any value passed as
parameter then check your .cs(.net) file that look like this:
[ServiceContract]
public interface IDynamicWCFService
{
[OperationContract]
string HelloYesterday(string test);
}
The variable name passes here, have to match with when you call it in PHP. I am taking it as “test” for my examples below.
Example #1: using php-soap with single parameter for HelloYesterday function
<?php
$url="http://99-mxl9461k9f:6062/DynamicWCFService.svc?WSDL";
$client = new SoapClient($url, array( "trace" => 1 ));
$result = $client->HelloYesterday(array('test' => 'this is a string'));
var_dump($result);
$respXML = $client->__getLastResponse();
$requXML = $client->__getLastRequest();
echo "Request: <br>";
var_dump($requXML);
echo "Response: <br>";
var_dump($respXML);
?>
Example #2 : using nusoap with single parameter for HelloYesterday function
<?php
require_once('../lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$url="http://99-mxl9461k9f:6062/DynamicWCFService.svc?WSDL";
$client = new nusoap_client($url, 'wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword); $client->soap_defencoding = 'UTF-8'; // this is only if you get error of soap encoding mismatch.
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
// Doc/lit parameters get wrapped
$param = array('test' => ' This is a string for nusoap');
$result = $client->call('HelloYesterday', array('parameters' => $param), '', '', false, true);
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
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->debug_str, ENT_QUOTES) . '</pre>';
?>
One more example… passing array as a parameter or pass mixed type parameter then check the following example:
Example #3: passing mixed type parameter including array parameter to Soap function.
Example of .net operation file
[ServiceContract]
public interface IDynamicWCFService
{
[OperationContract]
string[] HelloYesterday (string[] testA, string testB, int testC );
}
PHP code
<?php
$url="http://99-mxl9461k9f:6062/DynamicWCFService.svc?WSDL";
$client = new SoapClient($url, array( "trace" => 1 ));
$params = array(
"testA" => array(0=>"Value1",1=>"Value2",2=>"Value3"),
"testB" => “this is string abc”,
"testC" =>123
); // consider the first parameter is an array, and other parameters are string & int type.
$result = $client->GetData($params);
var_dump($result);
$respXML = $client->__getLastResponse();
$requXML = $client->__getLastRequest();
echo "Request: <br>";
var_dump($requXML);
echo "Response: <br>";
var_dump($respXML);
?>
Hope the above examples will help.
Since you're passing the wsdl location into the SoapClient constructor, you should be able to call $client->HelloTomorrow($args). There seem to be a few typos, though, can you verify that they are all correct in your actual code? In your web service code, you name the function HellowTomorrow but you're calling HelloTomorrow in your PHP code. Also, the parameter is named sret in your web service, but it's being passed as param1 in the $args associative array. Does it work calling HelloWorld() which doesn't expect any parameters?
Update:
See NuSOAP and content type
Try using the built-in PHP SoapClient instead of the NuSOAP version. PHP's SoapClient looks like it defaults to UTF-8, where NuSOAP seems to be hard-coded to ISO-8859-1

Categories