Jira PHP SOAP 更新问题不起作用

发布于 2024-12-06 16:44:51 字数 560 浏览 0 评论 0原文

我尝试使用 PHP 中的 SOAP 更新 Jira 中的问题组件,它没有抛出任何异常,它返回 isuue 但组件从未更新。

有什么想法吗?

这是我的示例代码:

$myIssue="";

$myIssue['components'][] = array("id" => "10769", "name" => "component name");

$soap->updateIssue($auth,"ISSUEKEY", $myIssue);

它只是返回问题,而不对组件进行任何更改。

这是当我打印该变量时从 php 发送的内容:

Array
(
    [components] => Array
        (
            [0] => Array
                (
                    [id] => 10769
                    [name] => component name
                )
        )
)

I tried updating component for issue in Jira using SOAP in PHP, it didnt throw any exception, it returned isuue but component was never updated.

Any ideas?

here is my sample code:

$myIssue="";

$myIssue['components'][] = array("id" => "10769", "name" => "component name");

$soap->updateIssue($auth,"ISSUEKEY", $myIssue);

It just returns issue without any change to component.

This is what is sent out of php when i print that variable :

Array
(
    [components] => Array
        (
            [0] => Array
                (
                    [id] => 10769
                    [name] => component name
                )
        )
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

难得心□动 2024-12-13 16:44:51

我不是 PHP 开发人员,但我认为这段代码:

arrayToObject(array("id" => "10769", "name" => "component name")

结果是:

{
    id: '10769',
    name: 'component name'
}

我对吗?

这将导致它作为 RemoteFieldValue 数组发送到 JIRA:

{components: [{
    id: '10769',
    name: 'component name'
}]}

如果是这样,我认为这不是 jira 所期望的。我相信它正在期待:

[
    {id: 'components',value:'component name'}
]

记住Java没有关联数组。所以构造 $myIssue['components'][] 对 Java 来说没有任何意义。 Java也不支持不同类型的多维数组。

更新:

尝试这个(或类似的东西,我的代码没有经过测试):

<?php

    class RemoteFieldValue {
        var $id;
        var $values = array();

        function __construct($idIn, $valuesIn) {
            $this->id = $idIn;
            $this->values = $valuesIn;
        }
    }

    $rfv = new RemoteFieldValue('components', array("id" =>"componentid_goes_here"));

    $rfvArray = array($rfv);

    $soap->updateIssue($auth,"ISSUEKEY", $rfvArray);


?>

当我在 ColdFusion 中组合 JIRA 服务时,我将每个 JIRA 对象(用户、问题、RemoteFieldValue 等)实现为 ColdFusion 对象。我怀疑您也可以使用关联数组和数组来完成此操作,但我发现这样更干净,并且更容易适应 JIRA SOAP 服务的期望。

I am not a PHP developer, but I think that this code:

arrayToObject(array("id" => "10769", "name" => "component name")

Results in this:

{
    id: '10769',
    name: 'component name'
}

Am I right?

Which would result in this being sent to JIRA as the RemoteFieldValue Array:

{components: [{
    id: '10769',
    name: 'component name'
}]}

If so, I do not think that is what jira is expecting. I believe it is expecting:

[
    {id: 'components',value:'component name'}
]

Remember that Java does not have associative arrays. So the construct $myIssue['components'][] doesn't mean anything to Java. Java also does not support multi-dimensional arrays of different types.

Update:

Try this (Or something like it, my code is not tested):

<?php

    class RemoteFieldValue {
        var $id;
        var $values = array();

        function __construct($idIn, $valuesIn) {
            $this->id = $idIn;
            $this->values = $valuesIn;
        }
    }

    $rfv = new RemoteFieldValue('components', array("id" =>"componentid_goes_here"));

    $rfvArray = array($rfv);

    $soap->updateIssue($auth,"ISSUEKEY", $rfvArray);


?>

When I put together a JIRA service in ColdFusion I implemented each JIRA object (User, Issue, RemoteFieldValue, etc) as a ColdFusion object. I suspect you could also do it with associative arrays and arrays, but I find this cleaner and it makes it easier to adapt to what the JIRA SOAP service expects.

泪意 2024-12-13 16:44:51

更新字段的最简单方法是传递对象

首先定义类(从 WSDL 生成)

class RemoteFieldValue {
  public $id; // string
  public $values; // ArrayOf_xsd_string
}

创建对象

$remoteField = new RemoteFieldValue ();
$remoteField->id = "12345"; 
$remoteField->value = "bla"; 

然后调用方法

$soap->updateIssue($auth,"ISSUEKEY", $remoteField );

希望这会有所帮助。

The easiest way to update a field is to pass the object

First define the class (generated from the WSDL)

class RemoteFieldValue {
  public $id; // string
  public $values; // ArrayOf_xsd_string
}

Create object

$remoteField = new RemoteFieldValue ();
$remoteField->id = "12345"; 
$remoteField->value = "bla"; 

then call the method

$soap->updateIssue($auth,"ISSUEKEY", $remoteField );

Hope this help.

梦幻的心爱 2024-12-13 16:44:51

对我来说 updateIssue 以这种方式工作(php)

定义类(来自 wsdl),

class RemoteFieldValue 
{
  public $id; // string
  public $values; // ArrayOf_xsd_string
}

之后这里是更新有问题的“描述”字段的代码。

public function updateDescription($issue_key, $description)
{
$remoteField = new RemoteFieldValue ();
$remoteField->id = 'description'; 
$remoteField->values = array($description); 

return $this->mSoapClient->updateIssue($this->mToken, $issue_key, array($remoteField));            
}

For me updateIssue works in such way (php)

Defining class (from wsdl)

class RemoteFieldValue 
{
  public $id; // string
  public $values; // ArrayOf_xsd_string
}

after that here is a code which updates 'description' field at issue.

public function updateDescription($issue_key, $description)
{
$remoteField = new RemoteFieldValue ();
$remoteField->id = 'description'; 
$remoteField->values = array($description); 

return $this->mSoapClient->updateIssue($this->mToken, $issue_key, array($remoteField));            
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文