我遇到了问题,因为我有一个带有wsHttpBinding的Web服务:
<endpoint address="" binding="wsHttpBinding" contract="BindingTest.IService1" />
Run Code Online (Sandbox Code Playgroud)
我无法让我的python代码调用它,每次我尝试调用时都会收到此错误消息:
Exception: (400, u'Bad Request')
Run Code Online (Sandbox Code Playgroud)
经过多次调查并在互联网上搜索后,我只是在我的Web服务中指定了basicHttpBinding:
<endpoint address="basic" binding="basicHttpBinding" contract="BindingTest.IService1" />
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我可以从python代码调用Web服务!
现在我的问题是另一个:我无法真正修改Web服务,我可以在本地尝试,但我没有权限修改它.
那么,有没有办法在python中指定一个"wsHttpBinding"请求?
这是我的实际代码:
import logging
from suds.client import Client
import sys
from suds.sax.element import Element
handler = logging.StreamHandler(sys.stderr)
logger = logging.getLogger('suds.transport.http')
logger.setLevel(logging.DEBUG), handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
client =Client('Service_URL')
client.set_options(headers={'Content-Type': 'application/soap+xml; charset=utf-8'})
result = client.service.RouteDocument('Input')
Run Code Online (Sandbox Code Playgroud) 我希望不要创建任何重复,但我环顾四周(堆栈溢出和其他论坛),我发现了一些类似的问题,但没有一个解决了我的问题。
我有一个 python 代码,唯一能做的就是查询数据库,在 Pandas 中创建一个 DataFrame 并将其写入 Excel 文件。
该代码在本地运行没有问题,但是当我在服务器中引入它时,它开始出现此错误:
File "Test.py", line 34, in <module>
test()
File "Test.py", line 31, in test
ex.generate_file()
File "/home/carlo/Test/Utility/ExportExcell.py", line 96, in generate_file
writer.save()
File "/usr/local/lib/python2.7/dist-packages/pandas/io/excel.py", line 1952, in save
return self.book.close()
File "/usr/local/lib/python2.7/dist-packages/xlsxwriter/workbook.py", line 306, in close
self._store_workbook()
File "/usr/local/lib/python2.7/dist-packages/xlsxwriter/workbook.py", line 677, in _store_workbook
xlsx_file.write(os_filename, xml_filename)
File "/usr/lib/python2.7/zipfile.py", line 1135, in write
zinfo = ZipInfo(arcname, date_time)
File "/usr/lib/python2.7/zipfile.py", line 305, in __init__
raise ValueError('ZIP does not support timestamps before 1980')
ValueError: …Run Code Online (Sandbox Code Playgroud) 我阅读了很多关于并且每个人都建议不要使用 Windows 上传并直接写入我的文件路径的建议;我什至尝试使用在论坛中找到的一些命令,例如:
swicthTo()
switch_to_window()
window_handles
Run Code Online (Sandbox Code Playgroud)
但我还没有找到任何解决方案。我的主要问题是当时我没有空间直接发送我的文件路径(见下图,介绍路径的空间是灰色的)但我只能选择单击“浏览”并打开 Windows上传者:
你知道如何切换到上传窗口的Windows并介绍我的文件吗?
我什至以这种方式尝试:
browse=wait(".//*[@id='fileinput']") #open the window upload
browse.click()
time.sleep(1)
def handle_dialog(element_initiating_dialog, dialog_text_input):
upload_dialog = driver.switch_to_active_element
print (upload_dialog)
upload_dialog.send_keys(dialog_text_input)
upload_dialog.send_keys(selenium.webdriver.common.keys.Keys.ENTER) # the ENTER key closes the upload dialog, other thread exits
handle_dialog(browse, "foobar.txt")
Run Code Online (Sandbox Code Playgroud)
我找到了窗户,当我打印时,我有这个对象:
We are already in the Location->Details Page <bound method WebDriver.switch_to_active_element of <selenium.webdriver.ie.webdriver.WebDriver (session="3e725bb7-40a7-452a-ad90-9cca1d41296a")>>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试执行 send_keys 后,我收到此错误:
回溯(最近一次调用):文件“C:\Users\carlo.agresta\Desktop\IE - iQsonar.py”,第 149 行,在 handle_dialog(browse, "foobar.txt") 文件“C:\Users\carlo .agresta\Desktop\IE - iQsonar.py”,第 145 行,在 handle_dialog upload_dialog.send_keys(dialog_text_input) AttributeError: 'function' 对象没有属性 'send_keys'
我部分找到了一个解决方案,我让我的代码表现得好像窗口上传是一个警报,所以我这样做:
browse=wait(".//*[@id='fileinput']")
browse.click()
time.sleep(1) …Run Code Online (Sandbox Code Playgroud) 我已经阅读了关于从str到dic的python转换的不同帖子,但我仍然有问题,我无法在字典中转换我的str.
这是我原来的字符串:
{"faqId":1,"isPrivate":false,"question":"Question 1","answer":"# Hello world!!\r\n\r\n* Proin elementum sollicitudin sodales.\r\n* Nam id erat nec nibh dictum cursus.\r\n\r\n> In et urna eros. Fusce molestie, orci vel laoreet tempus, sem justo blandit magna, at volutpat velit lacus id turpis. \r\n> Quisque malesuada sem at interdum congue. Aenean dapibus fermentum orci eu euismod.\r\n\r\n\r\n\r\n[This is an example link to nothing]()\r\n"},{"faqId":2,"isPrivate":false,"question":"Question 2","answer":"Dillinger\r\n=========\r\n\r\nDillinger is a cloud-enabled HTML5 Markdown editor.\r\n\r\n - Type some Markdown text in the left window\r\n - See the HTML in the right\r\n - …Run Code Online (Sandbox Code Playgroud) python ×3
python-2.7 ×2
c# ×1
dictionary ×1
file-upload ×1
json ×1
pandas ×1
selenium ×1
string ×1
ubuntu-16.04 ×1
xlsxwriter ×1