我正在将Python代码转换为Java。代码是soap1.5客户机代码,它与SOAP服务器端点通信。你知道吗
没有意义的是,Python代码发送XML请求并从服务器获取可接受的响应。但是,对于Java代码,响应是一个错误,说明“请求的格式不正确”。你知道吗
下面我展示了XML请求,一个用Python发送,另一个用Java发送。Java发送的javaone怎么会返回一个错误,但是Python是可以接受的。它们都是有效的请求。或者我遗漏了一些明显的东西。你知道吗
Python中的请求:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:cs="urn://Ocpp/Cp/2012/06/">
<SOAP-ENV:Header>
<cs:chargeBoxIdentity>Test</cs:chargeBoxIdentity>
<wsa:MessageID>Fake OCPP571322528896</wsa:MessageID>
<wsa:Action>/ChangeConfiguration</wsa:Action>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cs:changeConfigurationRequest>
<cs:key>LaMa_ConnectionRate</cs:key>
<cs:value>5120</cs:value>
</cs:changeConfigurationRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Java请求:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cs="urn://Ocpp/Cp/2012/06/"
xmlns:wsa="http://www.w3.org/2005/08/addressing">
<SOAP-ENV:Header>
<cs:chargeBoxIdentity>Test</cs:chargeBoxIdentity>
<wsa:Action>/ChangeConfiguration</wsa:Action>
<wsa:MessageID>Fake OCPP571322528896</wsa:MessageID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cs:changeConfigurationRequest>
<cs:key>LaMa_ConnectionRate</cs:key>
<cs:value>5120</cs:value>
</cs:changeConfigurationRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Java故障响应:
<?xml version="1.0" encoding="UTF-8"?><env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<env:Fault>
<env:Code>
<env:Value>env:Sender</env:Value>
</env:Code>
<env:Reason>
<env:Text xml:lang="en-US">XML Request is not well formed!</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>
更新:
我的Java代码应该为“SOAP-ENV”发送“http://www.w3.org/2003/05/soap-envelope”,如下所示。但是,它以某种方式发送“http://schemas.xmlsoap.org/soap/envelope/”。我不明白为什么。你知道吗
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope");
目前没有回答
相关问题 更多 >
编程相关推荐