WSO2:通过Web服务更新用户角色

时间:2016-08-22 10:13:40

标签: wso2is wso2-am

我安装了WSO2 API-M并尝试更新用户的角色。

我的要求机构:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.axis2/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:addRemoveRolesOfUser>
         <!--Optional:-->
         <xsd:userName>tom</xsd:userName>
         <!--Zero or more repetitions:-->
         <xsd:newRoles>internal/subscriber</xsd:newRoles>
         <!--Zero or more repetitions:-->
         <xsd:deletedRoles>admin</xsd:deletedRoles>
      </xsd:addRemoveRolesOfUser>
   </soap:Body>
</soap:Envelope>

我的回答:

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Body>
        <soapenv:Fault>
            <soapenv:Code>
                <soapenv:Value>soapenv:Receiver</soapenv:Value>
            </soapenv:Code>
            <soapenv:Reason>
                <soapenv:Text xml:lang="en-US">Error occurred while getting
                    database type from DB connection</soapenv:Text>
            </soapenv:Reason>
            <soapenv:Detail />
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

我尝试只删除角色是可以的,但无法添加新角色。

有没有人知道发生了什么事?

2016.08.23更新:

updateRolesOfUser的请求:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.axis2/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:updateRolesOfUser>
         <!--Optional:-->
         <xsd:userName>?</xsd:userName>
         <!--Zero or more repetitions:-->
         <xsd:newRoleList>?</xsd:newRoleList>
      </xsd:updateRolesOfUser>
   </soap:Body>
</soap:Envelope>

由于

汤姆

1 个答案:

答案 0 :(得分:1)

这是您应该如何发送请求以成功添加/更新/删除用户角色。

在同一回复中添加和删除角色:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:addRemoveRolesOfUser>
         <!--Optional:-->
         <xsd:userName>Tom</xsd:userName>
         <!--Zero or more repetitions:-->
         <xsd:newRoles>admin</xsd:newRoles>
         <!--Zero or more repetitions:-->
         <xsd:deletedRoles>test</xsd:deletedRoles>       
      </xsd:addRemoveRolesOfUser>
   </soapenv:Body>
</soapenv:Envelope>

仅添加新角色(删除deletedRoles元素):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:addRemoveRolesOfUser>
         <!--Optional:-->
         <xsd:userName>Tom</xsd:userName>
         <!--Zero or more repetitions:-->
         <xsd:newRoles>admin</xsd:newRoles>       
      </xsd:addRemoveRolesOfUser>
   </soapenv:Body>
</soapenv:Envelope>

更新新角色:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:updateRolesOfUser>
         <!--Optional:-->
         <xsd:userName>Tom</xsd:userName>
         <!--Zero or more repetitions:-->
         <xsd:newRoleList>test</xsd:newRoleList>
         <xsd:newRoleList>admin</xsd:newRoleList>
         <xsd:newRoleList>Internal/subscriber</xsd:newRoleList>
      </xsd:updateRolesOfUser>
   </soapenv:Body>
</soapenv:Envelope>

注意:如果它显示零次或多次重复,如果没有传递任何值,则删除整个元素