首页 文章

ASMX WebServices问题

提问于
浏览
0

我们将以下请求发送到.Net 3.5 ASMX Web服务 .

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <Login xmlns="http://tempuri.org/" id="o0" SOAP-ENC:root="1">
          <password xsi:type="xsd:string">1234</password> 
          <userName xsi:type="xsd:string">Developer</userName> 
        </Login>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

在调试Web服务时,我们发现Web方法(登录和方法)可用的参数值为空 . 但是,如果我们从密码和用户名中删除xsi:type = "xsd:string"属性,一切正常 .
命名空间xsd指向http://www.w3.org/2001/XMLSchema,这是有效的 .
为什么.Net无法反序列化响应?为什么它不会抛出异常?顺便说一句:我们的服务定义将http://www.w3.org/2001/XMLSchema别名为"s" . 这可能是个问题吗?

亲切的问候,

2 回答

  • 1

    .NET序列化程序依赖底层模式来反序列化内容 . 指定xsi:type属性时,基本上会破坏架构 Contract .

    BTW . 不要使用http://tempuri.org/,组成自己的URI .

  • 1

    您的ASMX服务是否使用[SoapRpcService]属性修饰?如果没有,则它是文档/文字服务,并且不希望以该格式使用XML .

    这个XML是如何发送的?它是手工制作的吗?它是由基于源自“service.asmx?WSDL”的WSDL创建的Java客户端发送的吗?

相关问题