2016-08-22 92 views
0

我已經安裝了WSO2 API-M並嘗試更新用戶的角色。WSO2:通過Web服務更新用戶的角色

我的請求體:

<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年8月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

這是你應該如何發送請求到成功添加/更新/刪除用戶角色。

添加和刪除在同一響應角色:

<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> 

注意:如果它說零或更多的重複,刪除整個元素,如果你沒有通過任何值

+0

感謝您的答覆。你可以嘗試updateRolesOfUser嗎?我會在上面發帖。錯誤將是相同的,非常感謝。 –

+0

嘗試updateRolesOfUser。只有在新角色列表中添加一個角色時纔有效。我可以知道你的確切要求嗎? – Dilini

+0

我的要求是:管理員可以通過Web服務API更改用戶的角色。我的API-M版本是1.10.0。我嘗試updateRolesOfUser但失敗,所以我嘗試addRemoveRolesOfUser ...它也失敗了。 –