What is method signature in SOAP header? - php

I want to imitate the following SOAP request using Zend Framework but I don't understand the '__MethodSignature' part in header. Could someone please explain this?
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<h3:__MethodSignature xsi:type="SOAP-ENC:methodSignature"
xmlns:h3="http://schemas.microsoft.com/clr/soap/messageProperties"
SOAP-ENC:root="1">
xsd:string
</h3:__MethodSignature>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<i4:ReturnDataset id="ref-1"
xmlns:i4="http://schemas.microsoft.com/clr/nsassem/Interface.IReturnDataSet/Interface">
<tName id="ref-5">BU</tName>
</i4:ReturnDataset>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
When I call this ReturnDataSet function like this:
$client = new Zend_Soap_Client($wsdl_url, array('soap_version' => SOAP_1_1));
$tName = "BU";
$result = $client->ReturnDataset($tName);
Server throws an error. I think this header part is playing some role?

Try setting the MethodSignature or __MethodSignature SOAP header. With the normal PHP SOAP client, you do this as follows:
$client->__setSoapHeaders(new SoapHeader(
'http://schemas.microsoft.com/clr/soap/messageProperties',
'__MethodSignature',
'xsd:string'
));

Related

php new SoapClient with security header

we have soapclient connection problem. please check below xml and my php code and advice us. when we run in soap ui working well when are trying to run in local server not working.
working SoapUI XML request:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
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/">
<SOAP-ENV:Header>
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Timestamp wsu:Id="TS-2">
<wsu:Created>2017-07-03T09:38:05.550Z</wsu:Created>
<wsu:Expires>2017-07-03T09:48:05.550Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>xxxxxxx</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxxxxx</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:methodname
xmlns:ns2="http://ws.oprs.xxxxx.com/">
<arg0>
<actualClientIP>xxxxxx</actualClientIP>
<agentPanCard>xxxxxx</agentPanCard>
<userAuthKey>xxxxx</userAuthKey>
<userId>xxxxx</userId>
</arg0>
</ns2:methodname>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
above xml working fine in soap ui tool.
please check my php code.
private function apiMethodCall($url, $headerAuth, $className, $inputParams){
$soapClient = new SoapClient($url, $headerAuth);
$result = $soapClient->__soapCall($className, array($inputParams));
return $result;}
public function funcationName(){
$className = "methodname";
$headerAuth = array("UsernameToken"=>array("Timestamp"=>array("Created"=>"2017-07-03T09:40:00.550Z","Expires"=>"2017-07-03T09:50:00.550Z"),"UsernameToken"=>array("Username"=>"XXXXXX", "Password"=>"xxxxxxx")));
$inputParams =Array("arg0"=> Array("actualClientIP"=>"xxxxxx","agentPanCard"=>"xxxxxx","userAuthKey"=>"xxxxxxx","userId"=>"xxxxxx"));
$arr_chart = $this->apiMethodCall("http://xxxxxxxxxxxxx?wsdl", $headerAuth, $className, $inputParams);
print_r($arr_chart);
}
getting Below error
Fatal error: Uncaught SoapFault exception: [Client] looks like we got
no XML document in
SoapClient->__soapCall('methodname', Array)

Need to delete ns1: from soap call to the server

I use SOAP as a method to communicate with the asp.net service. The problem is that I need to pass the XML without ns1: .
This is the request I send now:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ex.ex.com/">
<SOAP-ENV:Body>
<ns1:GetInfoFromSending>
<ns1:Key>XXX</ns1:Key>
<ns1:ObjectID>2468</ns1:ObjectID>
</ns1:GetInfoFromSending>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But the format of the request needed is this:
<?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:Body>
<GetInfoFromSendingList xmlns="http://ex.ex.com/">
<Key>string</Key>
<ObjectID>int</ObjectID>
</GetInfoFromSendingList>
</soap:Body>
</soap:Envelope>
I tried using MSSoapClient from PHP Manual but doesn't seem to work
try {
$soap = new MSSoapClient($wsdl, $options);
var_dump($soap);
$data = $soap->__soapCall('GetInfoFromSending', array('parameters'=>$params));
var_dump($soap);
}
catch(Exception $e) {
die($e->getMessage());
}
What is $namespace = "http://tempuri.com"; in MSSoapClient
Resolved by using the default __soapCall from SOAP.

Wrong SOAP Tags in PHP SOAP Request

I'm trying to send an SOAP request.
My request looks like this
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="someurl">
<SOAP-ENV:Body>
<RequestIndBApplication>
But my customer told me it has to look like this
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<process xmlns="someurl">
<RequestIndBApplication>
I'm using an WSDL file i got from my customer. But i don't know how i can change the soap tag. is there a way to do this?
Here is my php code
$client = new SoapClient('urlofwsdlfile',array('trace' => true, 'exceptions' => true)); $params = new \SoapVar($xmlstr), \XSD_ANYXML);
$result = $client->__SoapCall('process', array($params));
$xmlstr contains the data as xml

PHP soapClient for Paypal SetExpressCheckout Authentication Failure

This is current Soap message send to soap paypal API :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:ebay:apis:eBLBaseComponents"
xmlns:ns2="ebl:SetExpressCheckoutRequestDetails"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns3="urn:ebay:api:PayPalAPI"
xmlns:ns4="ebl:UserIdPasswordType">
<SOAP-ENV:Header>
<ns3:RequesterCredentials xsi:type="ns4:UserIdPasswordType">
<Username>xxxxx</Username>
<Password>xxxxx</Password>
<Signature>xxxxx</Signature>
</ns3:RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns3:SetExpressCheckoutReq>
<ns3:SetExpressCheckoutRequest>
<ns1:Version>84.0</ns1:Version>
<ns1:SetExpressCheckoutRequestDetails
xsi:type="ns2:SetExpressCheckoutRequestDetailsType">
<ReturnUrl>url_to_/success.paypal.php</ReturnUrl>
<CancelUrl>url_to_/cancel.paypal.php</CancelUrl>
<LocaleCode>US</LocaleCode>
</ns1:SetExpressCheckoutRequestDetails>
</ns3:SetExpressCheckoutRequest>
</ns3:SetExpressCheckoutReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I instantiated this PHP5 SoapClient :
//Endpoint
$location = 'https://api-3t.sandbox.paypal.com/2.0/';
$uri = 'urn:ebay:api:PayPalAPI';
//SoapClient options
$options = array('trace' => 1, 'exceptions' => 1, 'location'=>$location, 'uri'=>$uri);
//My Soap Client
$client =new SoapClient('https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl',$options);
But when I called SetExpressCheckout paypal soap service, i receive the following soap message :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cc="urn:ebay:apis:CoreComponentTypes"
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:ed="urn:ebay:apis:EnhancedDataTypes"
xmlns:ebl="urn:ebay:apis:eBLBaseComponents"
xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"
xsi:type="wsse:SecurityType"></Security>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"
xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents"
xsi:type="ebl:UserIdPasswordType">
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">
2012-01-13T12:09:01Z
</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">
c8d551f118a1
</CorrelationID>
<Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
<ShortMessage xsi:type="xs:string">
Authentication/Authorization Failed
</ShortMessage>
<LongMessage xsi:type="xs:string">
You do not have permissions to make this API call
</LongMessage>
<ErrorCode xsi:type="xs:token">10002</ErrorCode>
<SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">
Error
</SeverityCode>
</Errors>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">84.0</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">2271164</Build>
</SetExpressCheckoutResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Nevertheless, I used the API credentials of my business account test...
I don't understand why my code doesnt work.
The error is : 'You do not have permissions to make this API call', but how it's possible? Because i use the correct endpoint service (sandbox) ?
Someone can help me please?
You must use the API credentials of a Sandbox test account if you're connecting to the Sandbox API endpoint.
You can create a test account via https://developer.paypal.com/ > Test accounts > preconfigured.

Add namespace Prefix in Nusoap PHP

I'm using nusoap v 1.123, I'm trying to add the prefixes urn in my generated request of nusoap
This is what I am expecting
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:mnop:acceptor:contract">
<soapenv:Header>
<urn:authenticationHeader>
<urn:name>abctest</urn:name>
<urn:userid>dddd</urn:userid>
<urn:pass>errerere</urn:pass>
</urn:authenticationHeader>
</soapenv:Header>
and this is what the code is generating
<SOAP-ENV:Header>
<authenticationHeader>
<name>abctest</urn:name>
<userid>dddd</urn:userid>
<pass>errerere</urn:pass>
</authenticationHeader>
</SOAP-ENV:Header>
$header = new SoapHeader($wsdl, 'authenticationHeader',$headerParam);
$soapAction='urn:mnop:acceptor:contract';
$client = new nusoap_client($wsdl);
$client->setHeaders($headerParam);
$data=$client->call('myoperation',$bodyParam,$namespace,$soapAction,null,null,'document', 'literal');
the urn prefix is missing and SOAP-ENV: need to be replaced with soapenv: , kindly tell me to resolve this issue.
Thanks
this is how I solved this problem
$bodyParam = array('urn:operationName'=>array(
'urn:amount'=>'23232',
'urn:automati'=>'monUrl',
'urn:context'=>'',
'urn:currencyCode'=>'978',
'urn:customerId'=>'',
'urn:customerIpAddress'=>'',
'urn:customerLanguage'=>'fr',
));
Solved this problem, nusoap parameters must be configured
add global name space
$client->namespaces['tem'] = "http://tempuri.org/";
and add local namespace for elements
$responseService = $client->call(
'CAV_GET_DATA',
$param,
$namespace = 'tem'
);
Resolve
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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:tem="http://tempuri.org/" xmlns:ns6704="tem"><SOAP-ENV:Body><tem:CAV_GET_DATA><tem:UsuarioID>example</tem:UsuarioID><tem:Password>example</tem:Password><tem:idEmpleado>000000</tem:idEmpleado></tem:CAV_GET_DATA></SOAP-ENV:Body></SOAP-ENV:Envelope>

Categories