0

SOAP Web サービスを呼び出すためのコードを Python で取得しました。C# で同等のコードを書きたい。私は Python が初めてなので、C# で同等のクラスを見つけることができません。プロキシなどを作成してみましたが、うまくいきませんでした。助けてください。

import suds
from suds.client import Client
from suds.wsse import *
def main():

    url = 'https://webservices.cp.com/webservices/cphargepoint/services/4.1'
    wsdl = 'https://webservices.cp.com/api.wsdl'
    # API user and password
    api_user = 'yrewte44'
    api_pass = 'eg430'

    # create client and add security tokens in the soap header
    client = Client(url=wsdl, location=url)
    security = Security()
    token = UsernameToken(api_user, api_pass)
    security.tokens.append(token)
    client.set_options(wsse=security)
    try:
        # un-comment the print statement below to see the list of all published
        # CP service SOAP methods.
        # print client

        # getPublicStations() service method accepts a type of 'stationSearchRequest'
        searchQuery = client.factory.create('stationSearchRequest')
        # add properties/filter options
        searchQuery.Proximity = 10
        searchQuery.proximityUnit = 'M'
        # create goeData, provide starting point co-ordinates
        geoData = client.factory.create('geoData')
        geoData.Lat = 37.425758
        geoData.Long = -122.097807
        searchQuery.Geo = geoData

        # here is the actual call to the service        
        response = client.service.getPublicStations(searchQuery)
        # do whatever with the data
        # print response
    except suds.WebFault as detail:
        print detail

if __name__=="__main__":
    main()
4

1 に答える 1