I have a webservice with one one method that reurns an objetc, the method is very simple getObject(int id);
I made a PHP client to test it:
<?php
ini_set("soap.wsdl_cache_enabled", "1"); // Set to zero to avoid caching WSDL
$soapClient = new SoapClient('http://localhost:8080/ws-tickets/tickets2?wsdl');
$id = 2;
$result = $soapClient->get Ticket($id);
print_r($result);
?>
Well, I debug the WS when it is called by this php client and I see that the parameter received by it is ZERO.
If in my database I create a record that has "0" as id, the phpclient will retrieve it perfectly and every data is printed as it supouse to be for the print_r($result); command.
But, no mather wich parameter I send, it allways came to ZERO to the ws and I do not know what I am doing wrong
My Java WS is
#WebService
public class tickets2 {
#EJB
reciboDAO reciboDAO;
public ticket getTicket(int id){
recibo a = this.reciboDAO.getReciboporid(id);
return a;
}
}
Related
i am a beginner. I'm starting to learn Adobe Flash. I followed the code on Google on AS2:
l = new LoadVars();
l.onLoad = function(ok) {
ttl0=l.ttlslv0; atc0=l.atcslv0;
ttl1=l.ttlslv1; atc1=l.atcslv1;
};
l.sendAndLoad("http:localhost/getdata.php", l, "POST");
with php like this:
<?php
include_once("koneksi.php");
$qr = mysqli_query($con,"SELECT title, article from $tabel");
$nr = 0;
while($kolom=mysqli_fetch_row($qr) )
{
$ttl=$kolom[0];
$atc=$kolom[1];
echo "&ttlslv$nr=$ttl&atcslv$nr=$atc";
$nr++;
}
echo "&nr=$nr&";
?>
with the results that I can specify "what row" and "what column" will I take.
can this be changed to AS3 with the same results?
I have difficulty studying AS3
anyone want to give me a solution? thanx...
In AS3 you use the URLLoader class to load text/binary data. To work with URL-encoded strings you need the URLVariables class.
Something like that (not tested, no error handling either, just a common guideline):
// URLRequest instance holds various information
// about what, where and how you send.
var aRequest:URLRequest = new URLRequest;
// URL address.
aRequest.url = "http://localhost/getdata.php";
// Request method (POST or GET mostly).
aRequest.method = URLRequestMethod.POST;
// URLLoader instance performs the requested operations:
// uploads the request and relevant data, reads the answer,
// and dispatches all the events about any status changes.
var aLoader:URLLoader = new URLLoader;
// Tell the URLLoader that the answer is
// an URL-encoded text of key=value pairs.
aLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
// This event handler function will be triggered
// upon successfully completed operation.
aLoader.addEventListener(Event.COMPLETE, onData);
// Start loading.
aLoader.load(aRequest);
// The COMPLETE event handler function.
function onData(e:Event):void
{
// Unsubscribe from the event. For the most part it is
// a GOOD idea NOT to re-use any network-related
// class instances once they've done their job.
// Just unsubscribe from all their events,
// dismantle their data structures, purge
// any references to them and let the
// Garbage Collector do his job.
aLoader.removeEventListener(Event.COMPLETE, onData);
// Retrieve the object that contains key=value pairs.
var anAnswer:URLVariables = aLoader.data as URLVariables;
// The data you wanted to get.
trace(anAnswer.ttlslv0);
trace(anAnswer.atcslv0);
trace(anAnswer.ttlslv1);
trace(anAnswer.atcslv1);
}
UPD: It seems that you are dealing with escaped text there. I composed a simple script that explains how it works:
import flash.net.URLVariables;
var V:URLVariables = new URLVariables;
var S:String = "a=1&b=2";
V.decode(S);
trace(V.a); // 1
trace(V.b); // 2
S = escape(S);
trace(S); // a%3D1%26b%3D2
trace(unescape(S)); // a=1&b=2
V.decode(S); // Error #2101
So, there are two options you can work on:
Figure out why server passes the escaped string and prevent it.
Load the server's answer as a plain text (URLLoaderDataFormat.TEXT instead of VARIABLES) so the URLLoader.data will be just a simple String, then unescape(...) it if necessary and feed to the URLVariables.decode(...).
I hope you can help me with an issue with phone call dialings using Plivo PHP (new SDK 4.0). First I will indicate what I want to achieve:
- A client on my website wants to talk with an agent of main, so he introduces his telephone number in a form, choose an agent, and finally when submit, the website connect both of them dialing (this works). But then, (here begin my problems), I can't retrieve the call details (status, duration, initial and end dates of the call, etc...) for invoicing the client according to some of these details.
Edited 2018/02/23:
Ramya, the 600 error has dissapeared and everything seems to be ok as I see in the Plivo debug log. Below are my new codes (I think better done thanks to your instructions), and then, I show you the Plivo debud log (perhaps it's better you can see it inside my account, call made Feb 23, 2018 18:33:15), and finally I see my server debug error log is empty!.
The main problem is that dialstatus.php file, although seems to receive the parameters, I don't know how to access them because dialstatus.php does not execute showing the data in my monitor (in my code for example, this line never shows in the monitor screen:)
echo "Status = $estado, Aleg UUID = $aleg, Bleg UUID = $bleg";
So even though it receives the parameters, I can not access them to manipulate them, print them on the screen, do ifs with them, etc. May it be perhaps a permission problem with the files? (These php files have 6,4,4 permissions on my server, the same as the others).
Thank you!
Code 1: makecall.php
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient("**********", "**************************");
$telefono_cliente = "34*******";
$telefono_experto = "34*********";
$duracion = 50;
try {
$response = $client->calls->create(
"3491111111",
[$telefono_experto],
"https://www.ejemplo.com/llamar/response.php?telf=$telefono_cliente",
'POST',
[
'time_limit' => $duracion,
]
);
$id = $response->requestUuid;
echo "<br>Este es el requestUuid: " . $id . "<br><br>";
}
catch (PlivoRestException $ex) {
print_r($ex);
}
?>
Code 2: response.php
require 'vendor/autoload.php';
use Plivo\XML\Response;
$resp = new Response();
$params = array(
'callerId' => '3491111111',
'action' => "https://www.ejemplo.com/llamar/dialstatus.php",
'method' => "POST",
'redirect' => "false"
);
$body3 = 'Desde ejemplo un cliente desea hablar con usted.';
$params3 = array(
'language' => "es-ES", # Language used to read out the text.
'voice' => "WOMAN" # The tone to be used for reading out the text.
);
$resp->addSpeak($body3,$params3);
$dial = $resp->addDial($params);
//$number = "34**********";
$number = $_GET['telf'];
$dial->addNumber($number);
Header('Content-type: text/xml');
echo($resp->toXML());
/*
Output:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Speak language="es-ES" voice="WOMAN">Desde ejemplo un cliente desea hablar con usted.</Speak>
<Dial redirect="false" method="POST" action="http://www.ejemplo.com/llamar/dialstatus.php" callerId="3491111111">
<Number>34********</Number>
</Dial>
</Response>
*/
?>
Code 3: dialstatus.php
// Print the Dial Details
$estado = $_REQUEST['DialStatus'];
$aleg = $_REQUEST['DialALegUUID'];
$bleg = $_REQUEST['DialBLegUUID'];
echo "Status = $estado, Aleg UUID = $aleg, Bleg UUID = $bleg";
?>
Plivo Sales Engineer here.
Redirect = true is used only when you want to continue the call by returning another XML in your action URL. For you use case, you don't have to use this parameter. Even if the Redirect is set to false, Plivo will make a request to the action URL with a list of parameters. I looked into your account (here) and I can see this request getting sent with DialStatus, ALegUUID, BLegUUID along with other parameters.
Dial Action URL is the best place to know the DialStatus and DialHangupCause.
You can find the call duration and billing amount in Hangup URL request as well. This Hangup URL can be configured in your first API call (to the expert). By default, hangup URL is set to Answer URL.
Please raise a support ticket with us for further assistance.
I'm trying to update a template document via PHP API using this: https://github.com/docusign/docusign-php-client/blob/master/src/Api/TemplatesApi.php#L4946
I get one of two errors depending on if I set the apply_document_fields option.
Without it set, I get UNSPECIFIED ERROR Value cannot be null.\r\nParameter name: fileBytes. However, if I view the request body before sending, document_base_64 is set as expected.
With apply_document_fields set 'true' (actual boolean value is not supported), I get FORMAT_CONVERSION_ERROR The data could not be converted.
Either way, it seems like the document data is not getting sent correctly, but I can't figure out how I'm supposed to be sending it. Here's my code:
public static function updateTemplateWithDocument(string $documentId, string $templateId, $documentBody = null)
{
$api = My_Service_Docusign::getInstance();
$templatesApi = new DocuSign\eSign\Api\TemplatesApi($api->getAuth());
$document = new \DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode($documentBody));
// Got an error reusing $documentId, so I'm incrementing it now
$document->setDocumentId((string) (((int)$documentId) + 1));
$def = new DocuSign\eSign\Model\EnvelopeDefinition();
$def->setDocuments(array($document));
$opts = new \DocuSign\eSign\Api\TemplatesApi\UpdateDocumentOptions();
// Different behavior with this set vs not
$opts->setApplyDocumentFields('true');
$res = $tmpApi->updateDocument($api->getAccountId(), $documentId, $templateId, $def, $opts);
return $res;
}
Unfortunately, DocuSign support doesn't support their API :-(
I figured out I need to use TemplatesApi::updateDocuments (plural) instead, which also allows me to reuse the documentId.
I am subscribing to data from a MQTT broker with phpMQTT. I have successfully set up a pub / sub routine based on their basic implementation. I can echo the information just fine inside the procmsg() function.
However, I need to take the data I receive and use it for running a few database operations and such. I can't seem to get access to the topic or msg received outside of the procmsg() function. Using return as below seems to yield nothing.
<?php
function procmsg($topic, $msg){
$value = $msg * 10;
return $value;
}
echo procmsg($topic, $msg);
echo $value;
?>
Obviously I am doing something wrong - but how do I get at the values so I can use them outside the procmsg()? Thanks a lot.
I dont know about that lib, but in that code
https://github.com/bluerhinos/phpMQTT/blob/master/phpMQTT.php ,
its possible see how works.
in :
$topics['edafdff398fb22847a2f98a15ca3186e/#'] = array("qos"=>0, "function"=>"procmsg");
you are telling it that topic "edafdff398fb22847a2f98a15ca3186e/#" will have Quality of Service (qos) = 0, and an "event" called 'procmsg'.
That's why you later wrote this
function procmsg($topic,$msg){ ... }
so in the while($mqtt->proc()) this function will check everytime if has a new message (line 332 calls a message function and then that make a call to procmsg of Source Code)
thats are the reason why you cannot call in your code to procmsg
in other words maybe inside the procmsg you can call the functions to process message ej :
function procmsg($topic,$msg){
$value = $msg * 10;
doStuffWithDataAndDatabase($value);
}
Note that you can change the name of the function simply ej :
$topics['edafdff398fb22847a2f98a15ca3186e/#'] = array("qos"=>0, "function"=>"onMessage");
and then :
function onMessage($topic,$msg){
$value = $msg * 10;
doStuffWithDataAndDatabase($value);
}
Sorry for my english, hope this help !
I'm writing an application that downloads an XML string from a URL and POSTs that to another URL (that's set up to handle an incoming "XML" field). I've got the first part right - it downloads the XML and I can alert() it and all that, but I'm unable to figure out how to POST that data to a server.
function pull() {
var myLoader = new air.URLLoader();
var myRequest = new air.URLRequest('http://something/something.xml');
myLoader.addEventListener(air.Event.COMPLETE, pulled);
myLoader.load(myRequest);
}
function pulled(evt) {
if (evt.target.bytesTotal>0) {
// alerting shows the full string just fine
alert(evt.target.data);
var myLoader = new air.URLLoader();
var myRequest = new air.URLRequest('http://someplace/push.php');
myRequest.method = air.URLRequestMethod.POST;
// myVars = new air.URLVariables("xml="+evt.target.data); //
// alert(evt.target.data.toUpperCase());
myRequest.data = "xml="+evt.target.data; // myVars;
myLoader.dataFormat = air.URLLoaderDataFormat.TEXT;
myLoader.addEventListener(air.Event.COMPLETE, pushed);
myLoader.load(myRequest);
}
}
I made the 2nd server PHP echo the contents of the xml variable, but I'm just unable to get the exact contents of the XML string. There is something I'm doing wring with the myRequest.data and/or dataFormat bit.
Can someone just figure this out? I know it's probably a simple thing, but I'm at my wit's end right now.
This is my first AIR app.
Another related question (or sub-question) is that...
alert(evt.target.data); // shows an alert box with the XML
alert(typeof evt.target.data); // shows String
alert(evt.target.data.toUpperCase()); // shows the xml converted to upper case
alert(encodeURI(evt.target.data)); // shows up blank.
alert(escape(evt.target.data)); // shows up blank.
Why??
The error seems to be the way you are assigning the parameters to 'data' ... Use URLVariables.
var params:URLVariables = new URLVariables();
params.[name of parameter] = [value];
--- so like params.xml = (YOUR XML) ... from your example:
// uses the dynamic object to add the 'xml' property to 'params' at runtime.
params.xml = evt.target.data
Then Change you request.data to request.data = params;
-- The URLVariables guy is dynamic - so you can add properties as I describe above.
For a basic example - much more complete that what I have here: http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html