0

I have a Java web service which has a web method with a HashMap as parameter. Now I'm using python to call that service. I use zeep library for web service client. I can call that function but the server doesn't receive my HashMap data. Server says it is empty (not null but empty)

I've tried to construct the HashMap in the client in many ways to make the server can recognize the data. But it doesn't work.

client = Client('http://113.161.71.189/TestService/Service?wsdl', transport=transport)
signCloudMetaData = client.get_type('ns0:signCloudMetaData')()
entry = []
pageNo = ('PAGENO', 'Last')
positionIdentifider = ('POSITIONIDENTIFIER', 'test')
rectangleOffset = ('RECTANGLEOFFSET', '-30,-100')

entry.append(pageNo)
entry.append(positionIdentifider)
entry.append(rectangleOffset)

signCloudMetaData.singletonSigning = entry
client.service.request(signCloudMetaData)

There is a sort of soap description for the object:

<xs:complexType name="signCloudMetaData">
    <xs:sequence>
        <xs:element name="singletonSigning">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="key" minOccurs="0" type="xs:string"/>
                                <xs:element name="value" minOccurs="0" type="xs:string"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>
Phương Vũ
  • 86
  • 1
  • 6

1 Answers1

0

Finally, I could successfully call the service with my colleague's helps. I post the solution for whom has the problem like me.

The Java HashMap is analyzed as Json object as below:

{ "entry":[ { "key":"POSITIONIDENTIFIER", "value":"test" }, { "key":"PAGENO", "value":"Last" } ] }

In python, you have to construct the object like this by using Dict type

position={}
position.update({"key":"POSITIONIDENTIFIER"})
position.update({"value":"test"})

pageNo={}
pageNo.update({"key":"PAGENO"})
pageNo.update({"value":"Last"})

Dict = {}
Dict['entry'] = []
Dict['entry'].append(position)
Dict['entry'].append(pageNo)

That's it.

Phương Vũ
  • 86
  • 1
  • 6