【问题标题】:Generating stubs with jax-ws fails使用 jax-ws 生成存根失败
【发布时间】:2012-08-28 08:05:53
【问题描述】:

我正在尝试使用 jax-ws 为 WSO2 身份服务器管理服务 https://xx.xx.xx.xx:9447/services/RemoteUserStoreManagerService?wsdl 生成存根。

我已经下载了 wsdl,但是当我运行时:

wsimport -p org.wso2 RemoteUserStoreManagerService.xml

我收到以下错误

    [ERROR] operation "updateCredential" has an invalid style
  line 679 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "setUserClaimValue" has an invalid style
  line 683 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUserClaimValues" has an invalid style
  line 692 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUserClaimValue" has an invalid style
  line 696 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateCredentialByAdmin" has an invalid style
  line 705 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteRole" has an invalid style
  line 739 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUser" has an invalid style
  line 748 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateRoleName" has an invalid style
  line 762 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateRoleListOfUser" has an invalid style
  line 766 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "addUser" has an invalid style
  line 780 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "addRole" has an invalid style
  line 784 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateUserListOfRole" has an invalid style
  line 788 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "setUserClaimValues" has an invalid style
  line 797 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateCredential" has an invalid style
  line 857 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "setUserClaimValue" has an invalid style
  line 878 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUserClaimValues" has an invalid style
  line 887 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUserClaimValue" has an invalid style
  line 908 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateCredentialByAdmin" has an invalid style
  line 917 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteRole" has an invalid style
  line 1010 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUser" has an invalid style
  line 1019 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateRoleName" has an invalid style
  line 1040 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateRoleListOfUser" has an invalid style
  line 1061 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "addUser" has an invalid style
  line 1094 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "addRole" has an invalid style
  line 1103 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateUserListOfRole" has an invalid style
  line 1112 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "setUserClaimValues" has an invalid style
  line 1121 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateCredential" has an invalid style
  line 1205 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "setUserClaimValue" has an invalid style
  line 1226 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUserClaimValues" has an invalid style
  line 1235 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUserClaimValue" has an invalid style
  line 1256 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateCredentialByAdmin" has an invalid style
  line 1265 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteRole" has an invalid style
  line 1358 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "deleteUser" has an invalid style
  line 1367 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateRoleName" has an invalid style
  line 1388 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateRoleListOfUser" has an invalid style
  line 1409 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "addUser" has an invalid style
  line 1442 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "addRole" has an invalid style
  line 1451 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "updateUserListOfRole" has an invalid style
  line 1460 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] operation "setUserClaimValues" has an invalid style
  line 1469 of file:/C:/tmp/RemoteUserStoreManagerService.xml

[ERROR] missing required property "style" of element "operation"


        Failed to parse the WSDL.

这是出现第一个错误的文件第 679 行附近的 wsdl 架构(未发布整个架构,因为它相当大):

       <wsdl:operation name="updateCredential">
        <wsdl:input message="ns:updateCredentialRequest" wsaw:Action="urn:updateCredential"/>
        <wsdl:fault message="ns:RemoteUserStoreManagerServiceUserStoreException" name="RemoteUserStoreManagerServiceUserStoreException" wsaw:Action="urn:updateCredentialRemoteUserStoreManagerServiceUserStoreException"/>
    </wsdl:operation>
    <wsdl:operation name="setUserClaimValue">
        <wsdl:input message="ns:setUserClaimValueRequest" wsaw:Action="urn:setUserClaimValue"/>
        <wsdl:fault message="ns:RemoteUserStoreManagerServiceUserStoreException" name="RemoteUserStoreManagerServiceUserStoreException" wsaw:Action="urn:setUserClaimValueRemoteUserStoreManagerServiceUserStoreException"/>
    </wsdl:operation>
    <wsdl:operation name="getUserClaimValuesForClaims">
        <wsdl:input message="ns:getUserClaimValuesForClaimsRequest" wsaw:Action="urn:getUserClaimValuesForClaims"/>
        <wsdl:output message="ns:getUserClaimValuesForClaimsResponse" wsaw:Action="urn:getUserClaimValuesForClaimsResponse"/>
        <wsdl:fault message="ns:RemoteUserStoreManagerServiceUserStoreException" name="RemoteUserStoreManagerServiceUserStoreException" wsaw:Action="urn:getUserClaimValuesForClaimsRemoteUserStoreManagerServiceUserStoreException"/>
    </wsdl:operation>

【问题讨论】:

    标签: jax-ws wso2


    【解决方案1】:

    尝试在所有 wsdl 操作中添加输出消息。有趣的是,wsimport 不会抱怨 getUserClaimValuesForClaims 操作,并且该方法已定义输出消息。

    编辑:您可以毫无顾忌地编辑 wsdl,因为这些有问题的方法具有 void 返回类型,因此您可以将任何您想要的作为返回类型并忽略它。换句话说,当调用 Web 服务时,您只对输入参数感兴趣,因为这些方法实际上不返回任何内容。因此,请执行以下操作:

    1. 复制 wsdl,例如将其命名为 client.wsdl
    2. 将输出消息添加到所有没有它的操作
    3. client.wsdl 生成 Web 服务客户端(不要更改服务!)
    4. 调用 Web 服务方法并忽略这些“有问题的”方法的返回类型

    【讨论】:

    • 我注意到了,但问题是这个服务是内置在 WSO2 碳核心中的,我不确定如何以及是否可以修改它。我想我需要某种解决方法。
    • 好吧,首先尝试在不修改服务的情况下调整 WSDL。有可能(虽然不确定这种特殊情况),已经做了很多次了。
    • 谢谢,我试过了,效果很好,但是出现了新的错误。
    【解决方案2】:

    Miljen Mikic 的回答非常出色,让我找到了正确的解决方案。我想我会举一个例子来说明如何按照他的建议去做。请注意错误列表中的错误是成对出现的:

    [ERROR] operation "updateCredential" has an invalid style
    line 679 of file:/C:/tmp/RemoteUserStoreManagerService.xml
    .
    .
    .
    [ERROR] operation "updateCredential" has an invalid style
    line 1205 of file:/C:/tmp/RemoteUserStoreManagerService.xml
    .
    .
    .
    

    OP 的 wsdl 示例仅包含前 2 个错误,但解决方案对所有人来说都是相似的。结果变成:

    <wsdl:operation name="updateCredential">
        <wsdl:input message="ns:updateCredentialRequest" wsaw:Action="urn:updateCredential"/>
        <wsdl:output message="" />
        <wsdl:fault message="ns:RemoteUserStoreManagerServiceUserStoreException" name="RemoteUserStoreManagerServiceUserStoreException" wsaw:Action="urn:updateCredentialRemoteUserStoreManagerServiceUserStoreException"/>
    </wsdl:operation>
    <wsdl:operation name="setUserClaimValue">
        <wsdl:input message="ns:setUserClaimValueRequest" wsaw:Action="urn:setUserClaimValue"/>
        <wsdl:output message="" />
        <wsdl:fault message="ns:RemoteUserStoreManagerServiceUserStoreException" name="RemoteUserStoreManagerServiceUserStoreException" wsaw:Action="urn:setUserClaimValueRemoteUserStoreManagerServiceUserStoreException"/>
    </wsdl:operation>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-07
      • 1970-01-01
      • 2012-11-06
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多