开发者

Accessing a web service

I have been trying to write a client to access a web service for work. I have successfully written clients using SUDS and ZSI with Python. I have used NetBeans 6.9 to assist in writing a few Java clients. The successful clients have all been accessing freely available web services I have found on the internet.

The client I need to connect to for work is not proving to be so friendly. It does require authentication:

http://www.cmicdataservices.com/datacenter/service.asmx

If I grab the WSDL descriptions of this web service I see there are six methods.

Methods (6):
    CheckIfAuthorized()
    DataProcessed()
    GetCurrentDataVer1()
    GetID()
    LogDSCStatus(xs:string _clientname, xs:string _status, xs:string _errormsg)
    ResetNewDataReferences()

There are 70 types returned as well. One of them being an Authentication type.

In my Python and Java clients I have been able to create these Authentication objects but have not been able to do anything further.

From the WSDL there is no indication to me that there is any way to create these authentication objects with what is available. The supplier of the web service does offer a client built using Adobe Air and I can test with that to ensure that I can authenticate to the webservice and consume it.

This is the first time I have had to interface with a web service and I am not sure if there is anything I am missing here. Can anyone tell me if there is something obvious that I am missing here as to how to authenticate with this service?

Here is the the P开发者_如何转开发ython client I wrote plus it's output. You can see a nice printout of the WSDL info if you uncomment the print client line.

#!/usr/bin/python

from suds.client import Client

url='http://www.cmicdataservices.com/datacenter/service.asmx?wsdl'
client = Client(url)


#print client
print client.service.CheckIfAuthorized()

The output:

Traceback (most recent call last):
  File "CMICTest.py", line 23, in <module>
    print client.service.CheckIfAuthorized()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg  /suds/client.py",      line 542, in __call__
 return client.invoke(args, kwargs)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py",  line 602, in invoke
  result = self.send(soapenv)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py",  line 649, in send
  result = self.failed(binding, e)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py",  line 702, in failed
  r, p = binding.get_fault(reply)
 File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/bindings /binding.py", line 265, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'Server was unable to process request. ---> Object reference not set to an instance of an object.'


try to use wireshark (or just debugging) to capture the full request and response for the working Adobe Air Client. Then capture the request/response of the client that you generated. compare the two requests and determine which objects that you are not creating and adding to your client.


The problem with your code is not generating of Authentication header for your CheckIfAuthorized call as it is required according to WSDL. Take a look at my answer to your other question that contains sample SOAP client created with suds that adds required header element to the request:

soap ui generated code

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜