I'm trying to write a simple web service server and client using nusoap. I think my server works fine because a VB.NET client can call it. However, the PHP client has a very long loading time and does not give any output.
server1.php
<?
require_once("nusoap/lib/nusoap.php");
$ns="localhost/";
$server = new soap_server();
$server->configureWSDL('TaxCalculator', $ns);
$server->wsdl->schemaTargetNamespace = $ns;
$server->register('TaxCalc', array('amount'=>'xsd:string'),array('return'=>'xsd:string'),$ns);
function TaxCalc($amount) {
$tax = $amount * 0.5;
return new soapval('return', 'xsd:string', $tax);
}
$server->service($HTTP_RAW_POST_DATA);
?>
client1.php
<?
require_once('nusoap/lib/nusoap.php');
$client=new soapclient('http://localhost/server1.php?wsdl', 'wsdl');
echo $client->call('TaxCalc', array('amount'=>'15.00'));
?>
I'm using PHP Version 5.2.6 and nusoap version 0.9.5.
I'd say use whatever works.
I have used nusoap.php,v 1.114 and it works for me.
The nuspoap_client call I have is different from what you have above. Yours does not have a paramter for what port to use.
$client = new nusoap_client("http://127.0.0.1:1024/soap/IApp", false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);
The 2nd parameter above says not to use a wsdl file.
I am guessing that maybe your VB client uses the same approach.
Your code looks like it wants to use a local wsdl file.
Alternatively maybe there is a permissions issue where VB is allowed to access the soap port and PHP is not. (doubt it as everything is local)
Related
I am using this PHP Kafka client library. Our Kafka is installed on server A and producer from different servers adding data in this using Java code, and now I am trying to consume data via PHP from server B. I need to pass the username and password to access data but in documentation, I am not getting any way to pass the username, password, and bootstrap server.
Java team using following details to add data in kafka
spring.kafka.bootstrap-servers=<value-here>
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username='<username>' password='<password>';
Now same, I am trying to achieve via PHP. How I can pass these parameters with my PHP code to consume data.
According to the documentation, try to do:
<?php
$conf = new \RdKafka\Conf();
$conf->set('sasl.jaas.config', "org.apache.kafka.common.security.plain.PlainLoginModule required username='<username>' password='<password>'");
$conf->set('security.protocol', "SASL_SSL");
$conf->set('sasl.mechanism', "PLAIN");
$consumer = new \RdKafka\Consumer($conf);
$consumer->addBrokers("<kafka_servers_list>");
Following is the solution of problem.
$conf = new RdKafka\Conf();
$conf->set('bootstrap.servers', '<pass-server-here>');
$conf->set('sasl.username', '<username>');
$conf->set('sasl.password', '<password>');
$conf->set('security.protocol', 'sasl_ssl');
$conf->set('sasl.mechanism', 'PLAIN');
$conf->set('group.id', 'anygroupID');
$conf->set('debug', 'all');
$rk = new RdKafka\Consumer($conf);
I can connect to a XML-RPC Server using this Class:
$this->xmlrpc->server('http://www.sometimes.com/pings.php', 80);
Now when the server with the client application is behind a Proxy with username and password authentication, how do I modify the above Class?
If I understand the Codeigniter Docs right (http://www.codeigniter.com/user_guide/libraries/xmlrpc.html?highlight=xml%20rpc#CI_Xmlrpc), the Class for example has to be modified to look like this:
$this->xmlrpc->server('http://www.sometimes.com/pings.php', 80, 'user:pass#proxy.com', 80);
Unfortunately this isn't working for me.
Load library first:
$this->load->library('xmlrpc');
and try something similar to this:
$this->xmlrpc->server('http://rpc.pingomatic.com/', 80);
$this->xmlrpc->method('weblogUpdates.ping');
$request = array('My Photoblog', 'http://www.my-site.com/photoblog/');
$this->xmlrpc->request($request);
if ( ! $this->xmlrpc->send_request())
{
echo $this->xmlrpc->display_error();
}
Sending XML-RPC Requests
Actually I can't find why that is not working. It's clearly guiding us what should be done.
I made it pull in the following way
// Make an object to represent our server.
$server = new xmlrpc_client('/api/sample.php','xmlrpc-c.sourceforge.net', 80);
// Set Proxy
$server->setProxy($proxyHost,$proxyPort,$proxyUsername='',$proxyPassword='',$proxyAuthType=1);
I have seen little to know instruction on using php to develop a client website to make remote calls to JiRA.
Currently I'm trying to make a soap client using JSP/Java to connect to a local jira instance. I would like to create and search issues that is all. We are currently having some problems using Maven2 and getting all the files we need from the repository since we are behind a major firewall(yes I've used the proxy).
I have a lot of experience with PHP and would like to know if using the PHP soapclient calls can get the job done.
http://php.net/manual/en/soapclient.soapclient.php
Yes it can be done, using SOAP or XML-RPC.
Using the APIs is pretty much straight forward - have a look at the API documentation to find the right functions for you. your code should look something like :
<?
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
...
... # get/create/modify issues
...
?>
Example of adding a new comment:
$issueKey = "key-123";
$myComment = "your comment";
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
$soapClient->addComment($token, $issueKey, array('body' => $myComment));
Example of creating an issue:
$issue = array(
'type'=>'1',
'project'=>'TEST',
'description'=>'my description',
'summary'=>'my summary',
'priority'=>'1',
'assignee'=>'user',
'reporter'=>'user',
);
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
$soapClient->createIssue($token, $issue);
Note that you need to install php-soap in linux (or it's equivalent in windows) to be able to use the SOAP library.
I am using the following code to read attendance data from a biometric device:
<?php
$options = array(
'location' => 'http://192.168.1.178/iWsService',
'uri' => 'http://www.zksoftware/Service/message/'
);
$client = new SoapClient(null, $options);
$soapRequest = "<GetAttLog><ArgComKey xsi:type=\"xsd:integer\">0</ArgComKey><Arg><PIN xsi:type=\"xsd:integer\">All</PIN></Arg></GetAttLog>";
$response = $client->__doRequest($soapRequest, 'http://192.168.1.178/iWsService', '', '1.1');
echo '<pre>', var_dump(htmlspecialchars($response, ENT_QUOTES)), '</pre>';
?>
This just works fine. But since we do not have the documentation/manual/API Reference for this particular device (and nowhere available), I have no clue on what other functions are available in this machine.
Is there any luck finding out what other SOAP parameters this device could accept?
Your help would be really valuable at this moment. Thank you!
At last I found the SOAP SDK Manual of zksoftware.
Since I was searching for the manual for almost a year, I am uploading it to my server for the benefit of future users:
http://www.myfurni.com/downloads/zksoftware_SOAPSDKManual.pdf
Edit:
The above link doesn't work anymore. Here is the new one:
https://drive.google.com/file/d/0ByvozREXZpckcHlHYnZoOTMtWjg/view?usp=sharing
I don't think it is possible. WSDL is the source of information about functions and arguments. No WSDL - no function list.
Try this It uses the UDP protocol to communicate to the Attendance Machine.
i am new to webservices,
I have created a basic stockmarket webservice, I have successfully created the server script for it and placed it in my server, Now I also creted a clent script and accessed it hruogh the same server.. Is it valid ? can boh files be accesed from the same server? or do I have to place them in different servers? If yes Then Y? If No then why do i get the blank page?
I am using nusoap library for webservice.
When I use my cleint script from my local machine I get these errors
"Deprecated: Assigning the return
value of new by reference is
deprecated in
D:\wamp\www\pranav_test\nusoap\lib\nusoap.php
on line 6506
Fatal error: Class 'soapclient' not
found in
D:\wamp\www\pranav_test\stockclient.php
on line 3"
stockserver.php at server
<?php
function getStockQuote($symbol) {
mysql_connect('localhost','root','******');
mysql_select_db('pranav_demo');
$query = "SELECT stock_price FROM stockprices "
. "WHERE stock_symbol = '$symbol'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
return $row['stock_price'];
}
require('nusoap/lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('stockserver', 'urn:stockquote');
$server->register("getStockQuote",
array('symbol' => 'xsd:string'),
array('return' => 'xsd:decimal'),
'urn:stockquote',
'urn:stockquote#getStockQuote');
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
stockclient.php
<?php
require_once('nusoap/lib/nusoap.php');
$c = new soapclient('http://192.168.1.20/pranav_test/stockserver.php');
$stockprice = $c->call('getStockQuote',
array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>
please help...
Please post a piece of source code.
Yes you can access your webservice from a client which is also located on the same server.
For testing webservices I recommend SoapUI, which is available for all platforms.
I recommend to use the build in soap extension of php then nusoap, it's an rather old library.
I'm really very new to PHP but i found the same error when i was working with nusoap.
what i understood that in php 5 you can't assign the return value of new object using referencing ( using the & operator) so simply... Remove it :D...
I did that i it worked.
to initiate a soap client with the new php version 5x - there is a conflict with the PHP5 soap library and the NuSoap library.
download the latest nusoap.php library for PHP version 5.3.x (you can get this from sourceforge)
Change the following class call in your client to:
$c = new soapclient
to
$c = new nusoap_client
You may also want to add the following to your PHP ini file.
[nusoap_deprecated]
; Turn off deprecated messages on rendered pages
error_reporting = E_ALL & ~E_DEPRECATED