Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Java - axis client failed to add Customers through web services
 
celuser
Jr. Member
 
Total Posts:  15
Joined:  2008-09-10
 

Hi all,

I am using Axis Java to connect to magento web services. Login is successful (and that known session issue is also fixed).

But I find it difficult to create the expected SOAP request for ‘customer.create’ operation.

<args SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">

The parameter named “args” should be an Array of Maps. (as I understood, correct me if I’m wrong). So I created a request as follows.

<?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:Body>
         <
ns1:call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Magento">
            <
sessionId xsi:type="xsd:string">1vp029hcubiiven8cr1s21nke2</sessionId>
            <
resourcePath xsi:type="xsd:string">customer.create</resourcePath>
            <
args soapenc:arrayType="xsd:anyType[1]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
               <
args href="#id0"/>
            </
args>
         </
ns1:call>
         <
multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Map" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://xml.apache.org/xml-soap">
            <
item>
               <
key xsi:type="soapenc:string">email</key>
               <
value xsi:type="soapenc:string">myemail13@domain.com</value>
            </
item>
            <
item>
               <
key xsi:type="soapenc:string">lastname</key>
               <
value xsi:type="soapenc:string">myLastName</value>
            </
item>
            <
item>
               <
key xsi:type="soapenc:string">firstname</key>
               <
value xsi:type="soapenc:string">MyFirstName</value>
            </
item>
         </
multiRef>
      </
soapenv:Body>
   </
soapenv:Envelope>

But if I set an array of java.util.Map as above, it results in an error message saying;
“SOAP-ERROR: Encoding: Can’t decode apache map, only Strings or Longs are allowd as keys”.

What is the correct way to set this parameter in the request SOAP with Axis? Any help is appreciated. (I have shown the correct SOAP created from php at the end).

Thanks.

-----------------------------------------------------------------------------------------------
SOAP request message created from a php SOAPClient is as follows.

<?xml version="1.0" encoding="UTF-8"?>
      
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <
SOAP-ENV:Body>
            <
ns1:call>
               <
sessionId xsi:type="xsd:string">mj3kj5rr2df0b1fq5kmputmr54</sessionId>
               <
resourcePath xsi:type="xsd:string">customer.create</resourcePath>
               <
args SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
                  <
item xsi:type="ns2:Map">
                     <
item>
                        <
key xsi:type="xsd:string">firstname</key>
                        <
value xsi:type="xsd:string">myFirstName</value>
                     </
item>
                     <
item>
                        <
key xsi:type="xsd:string">lastname</key>
                        <
value xsi:type="xsd:string">myLastName</value>
                     </
item>
                     <
item>
                        <
key xsi:type="xsd:string">email</key>
                        <
value xsi:type="xsd:string">myemail@mydomain.com</value>
                     </
item>
                  </
item>
               </
args>
            </
ns1:call>
         </
SOAP-ENV:Body>
      </
SOAP-ENV:Envelope>
 
Magento Community Magento Community
Magento Community
Magento Community
 
LindyKyaw
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2008-01-02
Los Angeles
 

The issue was caused by xsi:type.
Instead of

xsi:type="xsd:string"
axis has
xsi:type="soapenc:string"

Hopefully following forum link with help you:
soapenc:string vs xsd:string

 
Magento Community Magento Community
Magento Community
Magento Community
 
celuser
Jr. Member
 
Total Posts:  15
Joined:  2008-09-10
 

Hi LindyKyaw,

Thanks for the reply.

But this did not solve our problem as the SOAP request still is the same as above.

Following is part of the WSDL generated from magento

<definitions xmlns:typens="urn:Magento"
    
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    
xmlns="http://schemas.xmlsoap.org/wsdl/" name="Magento"
    
targetNamespace="urn:Magento">
    <
types>
        <
schema xmlns="http://www.w3.org/2001/XMLSchema"
            
targetNamespace="urn:Magento">
            <
import
                
namespace="http://schemas.xmlsoap.org/soap/encoding/"
                
schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
            <
complexType name="FixedArray">
                <
complexContent>
                    <
restriction base="soapenc:Array">
                        <
attribute ref="soapenc:arrayType"
                            
wsdl:arrayType="xsd:anyType[]" />
                    </
restriction>
                </
complexContent>
            </
complexType>
        </
schema>
    </
types>
    <
message name="call">
        <
part name="sessionId" type="xsd:string" />
        <
part name="resourcePath" type="xsd:string" />
        <
part name="args" type="xsd:anyType" />
    </
message
.....
<
definitions

Is there any issue in the above WSDL that causes these issues for me?

Waiting for a reply.

 
Magento Community Magento Community
Magento Community
Magento Community
 
celuser
Jr. Member
 
Total Posts:  15
Joined:  2008-09-10
 

Hi all,

Is there anyone who successfully called Magento web services through Java?

If so what is the tool used?

Can you please give some info on this?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
spdaly
Jr. Member
 
Total Posts:  14
Joined:  2008-07-14
Cincinnati, OH
 

Anyone have any luck with getting Java (specifically Axis 1.4) to work with Magento???

 
Magento Community Magento Community
Magento Community
Magento Community
 
panticz.de
Jr. Member
 
Total Posts:  19
Joined:  2009-01-16
Germany
 

Hello everybody!

I am currently writing a Magento Connector for Java. The goal is to create a free wrapper / library to manage Magento from a Java application. A few parts such as management of products, categories and pictures are already partially finished and can be used.

The latest version (source code and JAR package) can be downloaded from this homepage:
http://www.panticz.de/MagentoConnector/

If someone is interested in co-development, please contact my here.

Greeting
Pawel

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top