从 Blackberry 调用 .Net Web 服务时出错

发布于 2025-01-06 19:46:09 字数 2570 浏览 0 评论 0原文

我正在调用一个 .Net Web 服务,它采用复杂类型作为参数(使用 KSoap2)。我之前已经成功完成过此操作,因此我决定复制旧代码并将其粘贴到新方法中,当然将一些代码替换为与当前 Web 服务相关的代码。

我能看到的唯一真正的区别是新 Web 服务的 .asmx 的 URL 不同。

问题是我不断收到以下错误:(

当 SoapEnvelope.VER11 时,我收到以下错误)

org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body     (position:END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}soap:Fault>@1:338 in java.io.InputStreamReader@199cb474)

(当 SoapEnvelope.VER12 时,我收到以下错误)

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/soap/envelope/}soap:Envelope>@1:207 in java.io.InputStreamReader@5b209e72

为什么错误消息会根据我使用的 SOAP 版本而发生这样的变化?

我还尝试使用 HttpTransport.requestDump 打印我的信封,得到以下结果:

xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
    <v:Body>
        <postMessage xmlns="http://www.magnatech.com/" id="o0" c:root="1">
            <myMessage i:type="n0:Message" xmlns:n0="http://www.magnatech.com/">
                <messageContent i:type="d:string">HEY</messageContent>
                <userName i:type="d:string">TEST USERNAME</userName>
                <agentName i:type="d:string">TEST AGENT NAME</agentName>
                <userID i:type="d:string">0</userID>
                <agentID i:type="d:string">0</agentID>
                <fromAgent i:type="d:string">false</fromAgent>
                <messageID i:type="d:string"></messageID>
                <accountNumber i:type="d:string">TEST ACCOUNT</accountNumber>
            </myMessage>
        </postMessage>
    </v:Body>

看起来不错,实际上我对其他“WORKING”Web 服务调用中的信封做了同样的事情,它们是相同的,当然除了元素名称之外。

最后,这是 HttpTransport.responseDump 的输出:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Could not deserialize Soap message</faultstring></soap:Fault></soap:Body></soap:Envelope>

很明显,当我发送信封时,它有问题,但我没有发现它有任何问题。

可能是什么问题?我已经尝试了所有可能的方法,但已经没有想法了。

任何帮助都将不胜感激。

谢谢

I'm calling a .Net Web Service which takes a complex type as a parameter (using KSoap2). I've done this before successfully so I decided to just copy my old code and paste it into a new method, replacing some code with code relevant to the current web service of course.

The only real difference I can see is that the URL to the new web service's .asmx is different.

The thing is I keep getting the following error:

(I get the following when SoapEnvelope.VER11)

org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body     (position:END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}soap:Fault>@1:338 in java.io.InputStreamReader@199cb474)

(And the following when SoapEnvelope.VER12)

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/soap/envelope/}soap:Envelope>@1:207 in java.io.InputStreamReader@5b209e72

Why would the error message change like this depending on the version of SOAP I use?

I also tried printing out my envelope with HttpTransport.requestDump and I get the following:

xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
    <v:Body>
        <postMessage xmlns="http://www.magnatech.com/" id="o0" c:root="1">
            <myMessage i:type="n0:Message" xmlns:n0="http://www.magnatech.com/">
                <messageContent i:type="d:string">HEY</messageContent>
                <userName i:type="d:string">TEST USERNAME</userName>
                <agentName i:type="d:string">TEST AGENT NAME</agentName>
                <userID i:type="d:string">0</userID>
                <agentID i:type="d:string">0</agentID>
                <fromAgent i:type="d:string">false</fromAgent>
                <messageID i:type="d:string"></messageID>
                <accountNumber i:type="d:string">TEST ACCOUNT</accountNumber>
            </myMessage>
        </postMessage>
    </v:Body>

Which looks fine, I actually did the same thing with the envelope from my other "WORKING" web service call and they are the same, except for the element names of course.

And finally, here is the output from HttpTransport.responseDump:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Could not deserialize Soap message</faultstring></soap:Fault></soap:Body></soap:Envelope>

So obviously there is something wrong with the envelope as I'm sending it, yet I see nothing wrong with it.

What could be the problem? I've tried everything possible and am running out of ideas.

Any help at all will be greatly appreciated.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文