Magento 1.6 Soap v2 attributes and additional attributes - php

I am working with Magento 1.6 and try to call the Soap API V2 to get product-information (attributes and additional attributes).
If use soapUI or try to generate a request in java to get information of the product and its additional attributes a new entry gets written to the system log, saying:
2012-01-20T08:33:04+00:00 DEBUG (7): array_merge() [<a href='function.array merge'>function.array-merge</a>]: Argument #2 is not an array/opt/website/magento/app/code/core/Mage/Catalog/Model/Product/Api/V2.php
So I neither get those attributes nor can I update these on a product.
Does anybody have idea to come over this issue!
thanks

Well I figured it out!
There seems to be a "bug" in that file! So if you request only one attribute the array_merge() function can't join the variable because the $attribute variable is not an array.
Try to send multiple attributes with soaoUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
<soapenv:Header/>
<soapenv:Body>
<urn:catalogProductInfoRequestParam>
<sessionId>b595ed396f1901142cb284e4c280df82</sessionId>
<productId>7271</productId>
<!--Optional:-->
<store>0</store>
<!--Optional:-->
<attributes>
<additional_attributes>
<complexObjectArray>atribute</complexObjectArray>
<complexObjectArray>atribute</complexObjectArray>
<complexObjectArray>atribute</complexObjectArray>
<complexObjectArray>atribute</complexObjectArray>
<complexObjectArray>atribute</complexObjectArray>
</additional_attributes>
</attributes>
<!--Optional:-->
<identifierType/>
</urn:catalogProductInfoRequestParam>
</soapenv:Body>
</soapenv:Envelope>

Related

Calling multiple methods with same name using SoapClient

I have a SOAP webservice and in SOAP UI I see that there are methods with the same name. So, for example, there are 2 CreateNewContact methods, one of which takes 3 parameters and the other 4. Below are the stubs generated by SOAP UI
Method 1 Stub:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rfp="http://test.com/testWebservice/">
<soapenv:Header/>
<soapenv:Body>
<rfp:CreateNewContact_FullName>
<!--Optional:-->
<rfp:fullName>?</rfp:fullName>
<!--Optional:-->
<rfp:email>?</rfp:email>
<!--Optional:-->
<rfp:telNo>?</rfp:telNo>
</rfp:CreateNewContact_FullName>
</soapenv:Body>
</soapenv:Envelope>
Method 2 Stub:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rfp="http://test.com/testWebservice/">
<soapenv:Header/>
<soapenv:Body>
<rfp:CreateNewContact_FirstLastName>
<!--Optional:-->
<rfp:firstName>?</rfp:firstName>
<!--Optional:-->
<rfp:lastName>?</rfp:lastName>
<!--Optional:-->
<rfp:email>?</rfp:email>
<!--Optional:-->
<rfp:telNo>?</rfp:telNo>
</rfp:CreateNewContact_FirstLastName>
</soapenv:Body>
</soapenv:Envelope>
When I call the CreateNewContact method with 4 parameters using PHP SoapClient, it looks like I'm getting the response from the other method.
How can I specify which method to use using SoapClient?
Thanks,
As you can read here:
If you are using WSDL based SOAP requests and you have more than one
operation in your binding (with the same parameters), make sure the
style is set to rpc, NOT body! When you specify
'body' here, all that will be transmitted in the request is the
parameters for the function call, and SoapServer->handle() will use
the first function it finds with the same parameter-makeup to handle
the call. The actual method to call will only be included in the
request when your type is set to 'rpc', resulting in the expected
behavior
Therefore, you should check in your WSDL the operation element, which provides binding information from the abstract operation to the concrete SOAP operation.
For example:
<definitions ....>;
<binding .... >;
<operation .... >;
<soap12:operation soapAction="xs:anyURI" ?
soapActionRequired="xs:boolean" ?
style="rpc|document" ?
wsdl:required="xs:boolean" ? /> ?
</soap12:operation>
</binding>;
</definitions>
The style attribute value, if present, is a string that specifies the style for the operation. The style attribute indicates whether the operation is RPC-oriented (a messages containing parameters and return values) or document-oriented (a message containing documents). If the style attribute is omitted from the soap12:operation element, then the operation inherits the style specified or implied by the soap12:binding element in the containing wsdl:binding element.
So, in short, to solve your problem you should change the operation style from "document" to "rpc" in your WSDL.
As a further reference: https://bugs.php.net/bug.php?id=49169
I have faced the same with travelport universal API, I ended up modifying my local wsdl file to use different name for each method and it worked perfectly.

How to figure out Arguments for __soapCall()

Im trying to access a specific method from a webservice. i can access the webservice, i know because __getFunctions() is working. What i need to know is which arguments i have to pass, to call getItem(). In SoapUI a request looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://webservice.mks.com/2009/Integrity" xmlns:sch="http://webservice.mks.com/2009/Integrity/schema">
<soapenv:Header/>
<soapenv:Body>
<int:getItem>
<!--Optional:-->
<arg0 transactionId="?" sch:ItemId="8720303">
<sch:Username>--</sch:Username>
<sch:Password>--</sch:Password>
<sch:InputField>State</sch:InputField>
</arg0>
</int:getItem>
</soapenv:Body>
</soapenv:Envelope>
I think i have to pass a ItemId, Username, Password and InputField. But i have no Idea in which way i have to. I am using php and i called the method like this:
$result = $client->__soapCall('getItem',array('arg0'=>array('transactionId'=>'?','ItemId'=>'8720303','InputField'=>'State', 'Username'=>'--','Password'=>'--')));

Soap Php Example

I try to use some SOAP.
Here is what I have with SoapUI.
I Have to give Username,Password. But I dont know when I should put it.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:mob="http://schemas.datacontract.org/2004/07/Mobilog.Serveur.API.DTO.ParamRetour" xmlns:mob1="http://schemas.datacontract.org/2004/07/Mobilog.Serveur.API.DTO.ParamRetour.Dossiers3CE" xmlns:mob2="http://schemas.datacontract.org/2004/07/Mobilog.Serveur.API.DTO.Dossiers3CE">
<soapenv:Header/>
<soapenv:Body>
<tem:SaveDossier3CE>
<!--Optional:-->
<tem:paramSaveDossier3CE>
<!--Optional:-->
<mob:Authentification>?</mob:Authentification>
<!--Optional:-->
<mob:Origine>?</mob:Origine>
<!--Optional:-->
<mob:Password>?</mob:Password>
<!--Optional:-->
<mob:Username>?</mob:Username>
<mob:CodeUsr>?</mob:CodeUsr>
<!--Optional:-->
<?php
$soap = new SoapClient("file.wsdl");
$soap->SaveDossier3CE();
?>
Where Should I put the "Password / Origine" var ? I tried something like this :
<?php
$soap->SaveDossier3CE(array('username'=>'blabla'));
?>
Didnt work.
Any idea?
Usually they are sent as parameters to the function call.
$soap->SaveDossier3CE($username,$password);
As you seem to have access to the WSDL, I would advise you to try to generate the corresponding PHP classes that will show you how to easily send this sort of request.
I strongly advise you to use a WSDL to PHP generator such as PackageGenerator

FedEx XML Api Tracking Request Issues

I'm attempting to implement FedEx Package Tracking in a project using the XML api. The following is my tracking request:
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v6="http://fedex.com/ws/track/v6">
<soapenv '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v6="http://fedex.com/ws/track/v6">
<soapenv:Header/>
<soapenv:Body>
<v6:TrackRequest>
<v6:WebAuthenticationDetail>
<v6:UserCredential>
<v6:Key>'.fedex_accesskey.'</v6:Key>
<v6:Password>'.fedex_password.'</v6:Password>
</v6:UserCredential>
</v6:WebAuthenticationDetail>
<v6:ClientDetail>
<v6:AccountNumber>'.fedex_account.'</v6:AccountNumber>
<v6:MeterNumber>'.fedex_meter.'</v6:MeterNumber>
<v6:IntegratorId></v6:IntegratorId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:ClientDetail>
<v6:TransactionDetail>
<v6:CustomerTransactionId>Track By Number</v6:CustomerTransactionId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:TransactionDetail>
<v6:Version>
<v6:ServiceId>trck</v6:ServiceId>
<v6:Major>6</v6:Major>
<v6:Intermediate>0</v6:Intermediate>
<v6:Minor>0</v6:Minor>
</v6:Version>
<v6:PackageIdentifier>
<v6:Value>'.$tracking_number.'</v6:Value>
<v6:Type>TRACKING_NUMBER_OR_DOORTAG</v6:Type>
</v6:PackageIdentifier>
</v6:TrackRequest>
</soapenv:Body>
</soapenv:Envelope>';:Header/>
<soapenv:Body>
<v6:TrackRequest>
<v6:WebAuthenticationDetail>
<v6:UserCredential>
<v6:Key>'.fedex_accesskey.'</v6:Key>
<v6:Password>'.fedex_password.'</v6:Password>
</v6:UserCredential>
</v6:WebAuthenticationDetail>
<v6:ClientDetail>
<v6:AccountNumber>'.fedex_account.'</v6:AccountNumber>
<v6:MeterNumber>'.fedex_meter.'</v6:MeterNumber>
<v6:IntegratorId></v6:IntegratorId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:ClientDetail>
<v6:TransactionDetail>
<v6:CustomerTransactionId>Track By Number</v6:CustomerTransactionId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:TransactionDetail>
<v6:Version>
<v6:ServiceId>trck</v6:ServiceId>
<v6:Major>6</v6:Major>
<v6:Intermediate>0</v6:Intermediate>
<v6:Minor>0</v6:Minor>
</v6:Version>
<v6:PackageIdentifier>
<v6:Value>'.$tracking_number.'</v6:Value>
<v6:Type>TRACKING_NUMBER_OR_DOORTAG</v6:Type>
</v6:PackageIdentifier>
</v6:TrackRequest>
</soapenv:Body>
</soapenv:Envelope>';
All values are being swapped in correctly, and I am getting a success response back from FedEx. The issue is the response only has one tracking event. The event appears to be the last tracking update from FedEx (in this case, delivery time, date, and address) but is not showing any tracking events along the way.
Here is the response I get: Pastebin
As you can see, the package status is delivered, and the delivery address is listed in , but the origin and the steps along the way are not. Any suggestions on how to get all the tracking info and not just the most recent step? Help appreciated.
You were missing to set to true the IncludeDetailedScans element. Here is an example of a SOAP Envelope:
<?xml version="1.0" encoding="utf-8"?>
<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>
<TrackRequest xmlns="http://fedex.com/ws/track/v6">
<WebAuthenticationDetail>
<CspCredential>
<Key>CSP_KEY</Key>
<Password>CSP_PASSWORD</Password>
</CspCredential>
<UserCredential>
<Key>DEVELOPER_KEY</Key>
<Password>DEVELOPER_PASSWORD</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>ACCOUNT_NUMBER</AccountNumber>
<MeterNumber>METER_NUMBER</MeterNumber>
<ClientProductId>CLIENT_PRODUCT_ID</ClientProductId>
<ClientProductVersion>CLIENT_PRODUCT_VERSION</ClientProductVersion>
</ClientDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>6</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<PackageIdentifier>
<Value>TRACKING_NUMBER</Value>
<Type>TRACKING_NUMBER_OR_DOORTAG</Type>
</PackageIdentifier>
<IncludeDetailedScans>true</IncludeDetailedScans>
</TrackRequest>
</soap:Body>
</soap:Envelope>
Note that the previous request is only valid if you belong to the FedEx CSP program, if you don't, the code below is the right one for your:
<?xml version="1.0" encoding="utf-8"?>
<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>
<TrackRequest xmlns="http://fedex.com/ws/track/v6">
<WebAuthenticationDetail>
<UserCredential>
<Key>DEVELOPER_KEY</Key>
<Password>DEVELOPER_PASSWORD</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>ACCOUNT_NUMBER</AccountNumber>
<MeterNumber>METER_NUMBER</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>6</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<PackageIdentifier>
<Value>TRACKING_NUMBER</Value>
<Type>TRACKING_NUMBER_OR_DOORTAG</Type>
</PackageIdentifier>
<IncludeDetailedScans>true</IncludeDetailedScans>
</TrackRequest>
</soap:Body>
</soap:Envelope>
Best!
For Version 8, you need to add the following tag, almost at the very bottom of the XML request, right above the closing "TrackRequest" tag:
<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
I've found the solution hidden in the FedEx documentation. It is to supply 1 to get the full history. This value defaults to false and omits all that important tracking information.
I know this question wasn't geared towards .NET but if anyone arrives here (like I did) looking for a .NET specific answer to this question, here it is:
Dim request As New TrackRequest()
Dim options(0) As TrackRequestProcessingOptionType
options(0) = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS
request.ProcessingOptions = options

Soap header without header name php

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.

Categories