When using the ebay API, it make notification requests to your server which can look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
Stuff in header
</soapenv:Header>
<soapenv:Body>
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2015-02-22T16:19:51.956Z</Timestamp>
<Ack>Success</Ack>
<CorrelationID>3759873</CorrelationID>
<Version>885</Version>
<Build>E885_CORE_APIMSG_16971418_R1</Build>
<NotificationEventName>ItemRevised</NotificationEventName>
.
.
</GetItemResponse>
</soapenv:Body>
</soapenv:Envelope>
I define a function GetItemResponse then register it with the SOAP server object $server->addFunction("GetItemResponse");. The problem is that the function only gets passed the first element '' as the first argument. How do I get the full body passed to my function?
Try converting the result to XML object like below:
$xml = simplexml_load_string($response);
and pass $xml
Try this:
function GetItem($arg1, $arg2, $arg3){
var_dump(func_get_args());
}
$soapServer->addFunction('GetItem')
GetItemResponse is node name that holds a response to GetItem call. Also you should add more parameters to GetItem function if you need them.
More information about parameters: http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetItem.html
If you really need full body then override handle method from SoapServer. It will allow you to get whole body.
Related
I check the difference bettwen a call who work simulating soap with curl request which work here is the xml that work:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.test.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:DoItdoItRequest1>
<version>1.0</version>
</ser:DoItdoItRequest1>
</soapenv:Body>
</soapenv:Envelope>
I change my code using SoapClient to be more clean than emulating a curl request, but my server return me:
looks like we got no XML document
When debugging I get from client->__getLastRequest()
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://service.test.com/">
<SOAP-ENV:Body>
<ns1:DoItdoItRequest1>
<version>1.0</version>
</ns1:DoItdoItRequest1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The only difference seems to be:
<ser:DoItdoItRequest1>
against
<ns1:DoItdoItRequest1>
Do you know how to change this ns1: to a ser: with SoapClient ? an option maybe ?
I can't find helpful help about that...
Regards.
I need to debug a soap webservice but i don't know where to start.
This is returning wrong data and i need to find why.
It is running on http://localhost:18385 and i can control the parameters that i send but don't know the endpoint file .
if i write http://localhost:18385 on browser i get
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:IDSP="http://ns.adobe.com/InDesign/soap/" 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:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>HTTP GET method not implemented</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Thanks in advance
The easiest way to debug is to use an app like Postman or SoapUI, so you can set up what you post and see the response in detail.
You are getting an error because you are using GET in your script, InDesign Server expects POST request with Content-Type of xml/text and Body set to the Soap call, e.g.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://ns.adobe.com/InDesign/soap/">
<soapenv:Body>
<soap:RunScript>
<runScriptParameters>
<scriptLanguage>javascript</scriptLanguage>
<scriptFile>C:\InDesign\scriptfile.jsx</scriptFile>
<scriptArgs>
<name>myParameter</name>
<value>305</value>
</scriptArgs>
</runScriptParameters>
</soap:RunScript>
</soapenv:Body>
</soapenv:Envelope>
You're not giving much detail of what exactly you need.
If you're asking what's the WSDL path, it should be: http://localhost:18385/service?wsdl
If you need to debug a SOAP web service response you can either create a PHP test script using SoapClient or use SoapUI.
I need to send a SOAP request to a .NET Web Services (*.asmx). I am creating a WSDL SoapClient object and I need to make a __soapCall sending 2 parameters: LoginName and Password. The XML should be something like the exemple to work, but the XML created has the parameters all confused.
This is the code:
$client = new SoapClient("https://server/service.asmx?WSDL",array("trace"=>1,'soap_version' => SOAP_1_2));
$client->__setCookie('ticket',$ticket);
$param= array('LoginName'=>'name','Password'=> base64_encode('123456'));
$client->__soapCall('AddPlayer', $param);
echo "REQUEST:\n" . htmlentities($sweepStakesClient->__getLastRequest()) . "\n";
Also tried:
$param = array(new SoapParam('name','LoginName'),new SoapParam(base64_encode('123456'),'Password'));
Echo returns:
REQUEST: <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://server.com/Service">
<env:Body>
<ns1:AddPlayer/>
<Password>MTIyMzQ1NTY=</Password>
</env:Body>
</env:Envelope>
I need it to be something like:
<?xml version="1.0" encoding="utf-8"?>
<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>
<AddPlayer xmlns="http://server.com/Service">
<request>
<LoginName>name</LoginName>
<Password>MTIyMzQ1NTY=</Password>
</request>
</AddPlayer>
</soap12:Body>
</soap12:Envelope>
Please pay attention to the documentation provided on php.net regarding the method you use here, SoapClient::__soapCall():
This is a low level API function that is used to make a SOAP call. Usually, in WSDL mode, SOAP functions can be called as methods of the SoapClient object. This method is useful in non-WSDL mode when soapaction is unknown, uri differs from the default or when sending and/or receiving SOAP Headers.
You're in WSDL mode, so you don't need to use it at all. Instead call the method directly:
$client->AddPlayer('name', 'MTIyMzQ1NTY');
When you debug you should see that it matches up with the method name and the two parameters. In case not, fall-back to SoapClient::__call() and use the array with the named parameters again as second parameter. But it's much more comfortable to do it the WSDL style with named methods.
I need to access user name and password from the soap header inside php script. I can access the body information but could not access the header information.
Here is the SOAp...
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://schemas.xmlsoap.org/ws/2002/04/secext"
xmlns:met="http://www.example.com/data">
<soapenv:Header>
<sec:Security>
<UsernameToken>
<Username>ron</Username>
<Password>pass</Password>
</UsernameToken>
</sec:Security>
</soapenv:Header>
<soapenv:Body>
<met:columnInfo>
<databaseName>MySQL</adaptorName>
<tableName>product</tableName>
</met:columnInfo>
</soapenv:Body>
</soapenv:Envelope>
Any help will be really appreciated.
Ok found the solution for that.
$server = new SoapServer($anywsdl);
$server->addFunction(addAllFuntions);
$server->handle();
Then in the same php script,
function Security($data){
$UserToken=get_object_vars($data);
foreach($UserToken as $uToken){
$credentialArray=get_object_vars($uToken);
echo $credentialArray['Username'];
echo $credentialArray['Password'];
}
}
You would need $server->setClass($yourClass), if the Security() function was in different class.
I'm having a problem in order to create a soap call. As one can see the header that is being supplied from a 3rd party client doesn't have a header name. I need to create a soap call by passing the username and password to the soap request which doesn't have a name in the header. I have tried several examples but no success. The call below works in soap UI but I'm having serious problems when it comes to php. Any help would be much appreciated
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://namespace.example.com/">
<soapenv:Header>
<int:password>123</int:password>
<int:login>abc</int:login>
</soapenv:Header>
<soapenv:Body>
<int:getEventTree>
<!--Optional:-->
<lang>en</lang>
</int:getEventTree>
</soapenv:Body>
</soapenv:Envelope>
Please take a look at http://php.net/manual/en/soapclient.dorequest.php
You can use code like:
$response = $soapClient->__doRequest(
$request,
$endpoint,
$soapAction,
$soapVersion,
$one_way
);
$request could be defined as a string containing xml, such as:
$request =
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/""xmlns:int="http://namespace.example.com/">
<soapenv:Header>
<int:password>123</int:password>
<int:login>abc</int:login>
</soapenv:Header>
<soapenv:Body>
<int:getEventTree>
<!--Optional:-->
<lang>en</lang>
</int:getEventTree>
</soapenv:Body>
</soapenv:Envelope>';
You can define the rest of the arguments in the __doRequest() call depending on your configuration.