代码之家  ›  专栏  ›  技术社区  ›  Zoidberg

使用SpringWeb服务客户端解密消息

  •  10
  • Zoidberg  · 技术社区  · 16 年前

    还有华夫饼干给能帮我的人!

    我一直在努力解决这个问题 Spring XSD ).

    Here is the server side configuration

    The server's xwss security configuration

    The client's Spring configuration

    Client's xwss configuration

    [Fatal Error] :1:192: The prefix "ns0" for element "ns0:HolidayListResponse" is not bound.
    11-Dec-2009 7:45:32 AM com.sun.xml.wss.impl.apachecrypto.DecryptionProcessor decryptElementWithCipher
    SEVERE: WSS1203: Exception [ The prefix "ns0" for element "ns0:HolidayListResponse" is not bound. ] while trying to decrypt message
    

    And here is the SOAP response itself .

    这是编组映射文件

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                             "http://castor.org/mapping.dtd">
    <mapping>
        <field-handler name="dateHandler" class="com.mycompany.hr.handlers.DateFieldHandler" />
        <field-handler name="dateHandler2" class="com.mycompany.hr.handlers.DateFieldHandler" />
        <class name="com.mycompany.hr.data.Holiday">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="Holiday" />
            <field name="from" type="string" handler="dateHandler">
                <bind-xml name="StartDate" node="element" />
            </field>
            <field name="to" type="string" handler="dateHandler2">
                <bind-xml name="EndDate" node="element" />
            </field>
        </class>
        <class name="com.mycompany.hr.data.Employee">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="Employee" />
            <field name="number" type="java.lang.Integer">
                <bind-xml name="Number" node="element" />
            </field>
            <field name="firstName" type="java.lang.String">
                <bind-xml name="FirstName" node="element" />
            </field>
            <field name="lastName" type="java.lang.String">
                <bind-xml name="LastName" node="element" />
            </field>
        </class>
        <class name="com.mycompany.hr.data.HolidayRequest">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="HolidayRequest" />
            <field name="holiday" type="com.mycompany.hr.data.Holiday">
                <bind-xml name="Holiday" node="element" />
            </field>
            <field name="employee" type="com.mycompany.hr.data.Employee">
                <bind-xml name="Employee" node="element" />
            </field>
        </class>
    
        <class name="com.mycompany.hr.data.HolidayConfirmation">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="HolidayConfirmation" />
            <field name="confirmationCode" type="java.lang.Integer">
                <bind-xml name="ConfirmationCode" node="element" />
            </field>
            <field name="confirmationMessage" type="java.lang.String">
                <bind-xml name="ConfirmationMessage" node="element" />
            </field>
        </class>
    
        <class name="com.mycompany.hr.data.HolidayResponse">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="HolidayResponse" />
            <field name="confirmation" type="com.mycompany.hr.data.HolidayConfirmation">
                <bind-xml name="HolidayConfirmation" node="element" />
            </field>
        </class>
        <class name="com.mycompany.hr.data.HolidayListRequest">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="HolidayListRequest" />
            <field name="id" type="java.lang.Integer">
                <bind-xml name="userId" node="element" />
            </field>
        </class>
        <class name="com.mycompany.hr.data.HolidayListResponse">
            <map-to ns-uri="http://mycompany.com/hr/schemas" ns-prefix="ns0" xml="HolidayListResponse" />
            <field name="holidays" type="com.mycompany.hr.data.Holiday" collection="vector">
                <bind-xml name="Holiday" node="element" />
            </field>
        </class>
    </mapping>
    

    我知道这是很多信息,但我想我会提供一切。我的加密设置正确吗?不可能在客户端对消息体进行加密和解密吗?在这一点上,我愿意接受几乎任何建议。

    2 回复  |  直到 16 年前
        1
  •  2
  •   Peter Mortensen Pieter Jan Bonestroo    16 年前

    看看 CastorMarshaller 属性,并尝试将某些“忽略”属性设置为true(在 <bean id="castorMarshaller"

    <property name="validating" value="false" />
    <property name="suppressNamespaces" value="true" />
    <property name="ignoreExtraElements" value="true" />
    

        2
  •  0
  •   Peter Mortensen Pieter Jan Bonestroo    16 年前

    你确定吗

     <property name="xsd" value="classpath:src/java/hr.xsd"/>
    

    问题是否得到妥善解决?

    您得到的错误表明它找不到如何处理该元素。如果响应没有被解密,您将看不到元素名称和前缀。

    您是否能够在不加密的情况下验证和运行web服务?

    推荐文章