I'm trying to use nuSOAP to send a array with some data that will be use it on DB, but every time i get this "wsdl error: XML error parsing WSDL issue ... not well-formed (invalid token)" on my client.php
Here is my a little of my code on the server :
$server->register('cadastrar',
array('dados'=>'tns:cadastro'),
array('return'=>'xsd:string'),
$namespace,
$namespace.'#cadastrar',
'rpc',
'encoded',
''
);
$server->wsdl->addComplexType('cadastrar', 'complexType', 'struct', 'all','',
array(
'empresa' =>array ('name'=>'empresa','type'=>'xsd:string')
,'nome' =>array ('name'=>'nome','type'=>'xsd:string')
,'email' =>array ('name'=>'email','type'=>'xsd:string')
,'ddd' =>array ('name'=>'ddd','type'=>'xsd:string')
,'tel' =>array ('name'=>'tel','type'=>'xsd:string')
,'msg' =>array ('name'=>'msg','type'=>'xsd:string')
)
);
function cadastrar($dados){
//$objCliente = new Cliente();
//if($objCliente)
//$id = $objCliente->cadastroWebService($dados);
return $dados['empresa'];
}
and this is my code on the client :
$dados = array(
'empresa' => $_POST['empresa'],
'nome' => $_POST['nome'],
'email' => $_POST['email'],
'ddd' => $_POST['ddd'],
'tel' => $_POST['tel'],
'msg' => $_POST['msg']
);
//Chama o metodo call do SOAP
$result = $client->call('cadastrar', array('cadastro'=> $dados));
Anybody got any idea why isn't working ?
Thanks
I found what i was doing wrong when i was iniciating the client i was missing some arguments...
$client = new nusoap_client('http://www.domain.com/server.php?wsdl&debug=1', 'wsdl');
I just put the wsdl&debug=1', 'wsdl' and it work it
Related
I need to send a SOAP request that contains an element that repeats.
$params = array(
'UpdatedShipment' => array(
'OriginalShipDate'=>'2020-11-01',
'ShipmentInfo'=>array(
'Account' => 'XXXXX',
'ShipmentIdentificationNumber'=>'XXXXXXX',
'ServiceType'=>'P',
'PaperlessTradeEnabled'=>'1',
'SpecialServices'=>array(
'Service'=>array(
'ServiceType'=>'WY'
)
),
'IncludePreviousPieceLabels'=>'Y',
'DocumentImages'=> array(
'DocumentImage'=>array(
array('DocumentImageType'=>'INV','DocumentImage'=>base64_encode('xxxxxx'),'DocumentImageFormat'=>'PDF'),
array('DocumentImageType'=>'DCL','DocumentImage'=>base64_encode('xxxxxx'),'DocumentImageFormat'=>'PDF'),
)
)
),
)
);
$result = $s->UpdateShipmentRequest((array)($params));
It throws an exception:
SOAP-ERROR: Encoding: object has no 'DocumentImage' property
This is WSDL
https://wsbexpress.dhl.com/sndpt/updateShipment?WSDL
How can i resolve this?
Thanks
First, I have to say that I am totally new to WSDL-based Web Services using NuSOAP. I am trying to return an array of friends list from my soap server. Please find below my code listings as is:
Server:
//File includes omitted
function getFriendList($test = ''){
$results = array();
$results[] = array('name' => 'XXXXA1', 'surname' => 'XXXXA2');
$results[] = array('name' => 'XXXXXB1', 'surname' => 'XXXXB2');
$results[] = array('name' => 'XXXXXC1', 'surname' => 'XXXXC2');
return $results;
}
//Create server instance
$server = new soap_server();
//Configure our WSDL
$server->configureWSDL('server', 'urn:server');
//Add our Complex Type data type since we want to return an array
$server->wsdl->addComplexType(
'Friend',
'complexType',
'struct',
'all',
'',
array(
'name' => array('name' => 'name', 'type' => 'xsd:string'),
'surname' => array('name' => 'surname', 'type' => 'xsd:string')
)
);
//Register our array as a response
$server->wsdl->addComplexType(
'FriendArray',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:Friend[]')
),
'tns:Friend'
);
//Register the actual function that retuns the array but in the
//return n field specify the complex type of array we added onto the wsdl
$server->register('getFriendList',
array('test' => 'xsd:string'),
array('return' => 'tns:FriendArray'),
'urn:server',
'urn:server#getFriendList',
'document',
'encoded',
'Fetch a list of friends as an array. If you\'re not here sorry.'
);
//Serve the service
$server->service($HTTP_RAW_POST_DATA = (!isset($HTTP_RAW_POST_DATA)) ? $HTTP_RAW_POST_DATA : '');
With this, I hoped that I did everything correctly. I followed the standard procedure to make it work but in vein.
On the client side, I used the soap address url in wsdl and appended it with "?wsdl", so that it give me wsdl file dynamically.
example:
//Client call
$client = new nusoap_client("http://soapserver.dev/webroot/part_three/server.php?wsdl", true);
I have also taken labour of adding some whistles and bells on my client object as shown below:
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
This doesn't seem to help at all. I had experienced an issue earlier since my function accepts no parameter, where my service died because I didnt pass any parameter that speaks of inputs in my $client->call($name, $in, $out). I ended up providing an empty array and I got this error.
Could this be related to the rpc/document parameter types of the register function?
Even using the wsdl file which I saved from my server url, I got the same error.
Can somebody please help me out here? Please!
I am trying to connect and use a WebService with PHP and SoapClient, but getting the following error
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in /www/1/html/webservices/tuev-nord-ass/soapclientconnect.php:21
I have SOAP already installed. But still dont know why i am getting this error. I am new to web services and might be doing mistake somewhere.
WSDL link:
http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl
My code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('soap.wsdl_cache_ttl', '0');
$wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
$options = array('trace' => true);
$client = new SoapClient($wsdl,
array(
'Benutzer' => 'desenbeck',
'Kennwort' => 'desenbeck',
'KonzernID' => '100',
'Händler-Nr' => 'INT31303',
'DMS-ID' => 'A13T2D19',
'encoding'=> 'ISO-8859-1'
)
);
//Returns list of available SOAP functions described in the WSDL for the Web service.
var_dump($client->__getFunctions());
//some parameters to send
$result = $client->Login('Benutzer', 'Kennwort', 'KonzernID', 'Händler-Nr', 'DMS-ID');
var_dump($result);
?>
Use a string indexed array for parameter:
$param = array ('user' => 'test',
'password' => 'test',
'corporate_group_id' => 'test',
'dealer_number' => 'test',
'dms_id' => 'test',
'dms_image_url' => 'test',
'dms_keepalive_url' => 'test',
'dms_followup_url' => 'test');
//some parameters to send
$result = $client->Login($param);
I never worked with SOAP XML api before.
I read a couple of similar questions on SO but I can't get it to work.
Here's a simple request:
<soap12:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap12=”http://www.w3.org/2003/05/
soap-envelope”>
<soap12:Body>
<CheckDomainAvailability xmlns=”https://live.domainbox.net/”>
<AuthenticationParameters>
<Reseller>myreseller</Reseller>
<Username>myuser</Username>
<Password>mypassword</Password>
</AuthenticationParameters>
<CommandParameters>
<DomainName>checkadomain.co</DomainName>
<LaunchPhase>GA</LaunchPhase>
</CommandParameters>
</CheckDomainAvailability>
</soap12:Body>
</soap12:Envelope>
I've contacted them but they do not offer a PHP API.
I would like to use the SoapClient class built in PHP.
The question is:
How do I send the request and print the answer?
Looks like your WSDL is located at https://live.domainbox.net/?WSDL.
Here's an example using the native PHP SoapClient.
$client = new SoapClient('https://live.domainbox.net/?WSDL');
// populate the inputs....
$params = array(
'AuthenticationParameters' => array(
'Reseller' => '',
'Username' => '',
'Password' => ''
),
'CommandParameters' => array(
'DomainName' => '',
'LaunchPhase' => ''
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
To get this working I needed to change the first line to get the right version of soap to 1.2.
Also a previous comment
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2));
// populate the inputs....
$params = array(
'AuthenticationParameters' => array(
'Reseller' => '',
'Username' => '',
'Password' => ''
),
'CommandParameters' => array(
'DomainName' => '',
'LaunchPhase' => ''
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
When i sending below request, i am getting 'Wrong Version" exception.
<OTA_HotelGetMsgRQ xmlns="http://www.opentravel.org/OTA/2003/05"
TimeStamp="2001-12-17T09:30:47.0Z" Version="4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Messages>
<Message HotelCode="123" HotelName="Test Hotel" ChainCode="321"
ReasonForRequest="Reservation Retrieval" RequestCode="Optional"
ChainName="Test Chain" MessageType="All" StartSeqNmbr="1"
EndSeqNmbr="10" />
</Messages>
</OTA_HotelGetMsgRQ>
above request is converted into zend code
$client = new zend_soap_client(null,
array(
'location' => 'http://url...',
'Uri' =>"http://www.opentravel.org/OTA/2003/05"
)
);
$request = array(
array('Messages'=>
array ('Message' =>
array (
'HotelCode' => '123',
'HotelName' => 'Test Hotel',
'ChainCode' => '321',
'ReasonForRequest' => 'Reservation Retrieval',
'RequestCode' => 'Optional',
'ChainName' => 'Test Chain',
'MessageType' => 'All',
'StartSeqNmbr' => '1',
'EndSeqNmbr' => '10'
)
)
)
);
$result = $client->OTA_HotelGetMsgRQ ($request);
Above line throws exception 'Wrong Version'. Anyone help me how to solve this
sounds like you are using the wrong version ;) - have you tried to add 'soap_version'=>'1.2' (or 1.1, depending on which version is needed) to the options of your soap_client?
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('Core_Soap_Test');
$autodiscover->setUri( sprintf($this->_WSDL_URI,0) );
$autodiscover->handle();
$this->_WSDL_URI = '"http://WWW.EXAMPLE.COM/soap/index/wsdl/%s/?wsdl'
try the code above. this helped me
I had this problem as well. The problem in my case was that I wasn't passing an expected (and thus required) parameter without throwing back a SoapFault-exception. Maybe it's useful to someone.