gpt4 book ai didi

Sonos 音乐 API 实现 "Unable to browse music"错误

转载 作者:行者123 更新时间:2023-12-03 20:29:43 38 4
gpt4 key购买 nike

我正在尝试实现 SMAPI 服务,但遇到了一些问题。

我建了一个 “fake” service它为这些端点提供硬编码响应:

  • getMediaURI
  • getLastUpdate
  • getMediaMetadata
  • 获取元数据
  • getExtendedMetadata
  • getSessionId

  • 我已按照添加自定义服务的说明进行操作,但未选中所有功能。

    我看到我的 Sonos iPhone 应用程序中列出了我的新测试服务,但是当我选择它时,我看到一个显示“无法浏览音乐”的屏幕。

    我不确定如何调试正在发生的事情,所以感觉就像在黑暗中刺伤一样。我不想推测性地做出可能与问题无关的更改 - 这似乎是浪费大量精力的秘诀。

    有没有办法查看 Sonos Controller 应用程序(客户端)的错误? 我查看了 http://[device ip]:1400/support/aggregate日志,但没有看到任何提及我的服务的域名,或看到任何似乎相关的内容。

    我知道(至少有一些)请求正在访问我的服务,特别是调用 getLastUpdategetMetadata .这是日志的输出:
    2016-02-23T18:55:24.316373+00:00 app[web.1]: Started POST "/soap/action" for 213.86.218.202 at 2016-02-23 18:55:24 +0000
    2016-02-23T18:55:24.316485+00:00 app[web.1]: Started POST "/soap/action" for 213.86.218.202 at 2016-02-23 18:55:24 +0000
    2016-02-23T18:55:24.431603+00:00 app[web.1]: Processing by SoapController#get_last_update as HTML
    2016-02-23T18:55:24.431611+00:00 app[web.1]: Processing by SoapController#get_last_update as HTML
    2016-02-23T18:55:24.438452+00:00 app[web.1]: params.inspect: {}
    2016-02-23T18:55:24.438458+00:00 app[web.1]: params.inspect: {}
    2016-02-23T18:55:24.447855+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.2.0/gems/wash_out-0.10.0/app/views/wash_out/document/response.builder (7.6ms)
    2016-02-23T18:55:24.447907+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.2.0/gems/wash_out-0.10.0/app/views/wash_out/document/response.builder (7.6ms)
    2016-02-23T18:55:24.448279+00:00 app[web.1]: Completed 200 OK in 17ms (Views: 9.5ms | ActiveRecord: 0.0ms)
    2016-02-23T18:55:24.457801+00:00 app[web.1]: Started POST "/soap/action" for 213.86.218.202 at 2016-02-23 18:55:24 +0000
    2016-02-23T18:55:24.448327+00:00 app[web.1]: Completed 200 OK in 17ms (Views: 9.5ms | ActiveRecord: 0.0ms)
    2016-02-23T18:55:24.464365+00:00 app[web.1]: Processing by SoapController#get_metadata as HTML
    2016-02-23T18:55:24.457861+00:00 app[web.1]: Started POST "/soap/action" for 213.86.218.202 at 2016-02-23 18:55:24 +0000
    2016-02-23T18:55:24.464428+00:00 app[web.1]: Processing by SoapController#get_metadata as HTML
    2016-02-23T18:55:24.465101+00:00 app[web.1]: params.inspect: {"id"=>"root", "index"=>0, "count"=>100}
    2016-02-23T18:55:24.465154+00:00 app[web.1]: params.inspect: {"id"=>"root", "index"=>0, "count"=>100}
    2016-02-23T18:55:24.472056+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.2.0/gems/wash_out-0.10.0/app/views/wash_out/document/response.builder (3.4ms)
    2016-02-23T18:55:24.472049+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.2.0/gems/wash_out-0.10.0/app/views/wash_out/document/response.builder (3.4ms)
    2016-02-23T18:55:24.472248+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 6.9ms | ActiveRecord: 0.0ms)
    2016-02-23T18:55:24.472251+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 6.9ms | ActiveRecord: 0.0ms)

    任何帮助将不胜感激!

    更新
    这是使用 SoapUI 对我的虚假服务发出请求的输出:
  • getLastUpdate
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sonos.com/Services/1.1">
    <soap:Body>
    <tns:getLastUpdateResponse>
    <getLastUpdateResult>
    <catalog>Catalog last updated 2016-02-18 11:52:30</catalog>
    <favorites>User: Rob last updated favorites 2016-02-18 12:01:00</favorites>
    <pollInterval>30</pollInterval>
    </getLastUpdateResult>
    </tns:getLastUpdateResponse>
    </soap:Body>
    </soap:Envelope>
  • getSessionId
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sonos.com/Services/1.1">
    <soap:Body>
    <tns:getSessionIdResponse>
    <getSessionIdResult>user0001</getSessionIdResult>
    </tns:getSessionIdResponse>
    </soap:Body>
    </soap:Envelope>
  • getMetadata
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sonos.com/Services/1.1">
    <soap:Body>
    <tns:getMetadataResponse>
    <getMetadataResult>
    <index>0</index>
    <count>2</count>
    <total>2</total>
    <mediaMetadata>
    <id>some_id_1</id>
    <title>Title 1</title>
    <mimeType>audio/mp4</mimeType>
    <itemType>track</itemType>
    <displayType>List</displayType>
    <summary>Summary text 1. Summary text 1. Summary text 1.</summary>
    <trackMetadata>
    <artistId/>
    <artist/>
    <composerId/>
    <composer/>
    <albumId/>
    <album/>
    <albumArtURI/>
    <albumArtistId/>
    <albumArtist/>
    <genreId/>
    <genre/>
    <duration/>
    <canPlay/>
    <canSkip/>
    <canAddToFavorites/>
    <rating/>
    <trackNumber/>
    </trackMetadata>
    <streamMetadata></streamMetadata>
    </mediaMetadata>
    <mediaMetadata>
    <id>some_id_2</id>
    <title>Title 2</title>
    <mimeType>audio/mp4</mimeType>
    <itemType>track</itemType>
    <displayType>List</displayType>
    <summary>Summary text 2. Summary text 2. Summary text 2.</summary>
    <trackMetadata>
    <artistId/>
    <artist/>
    <composerId/>
    <composer/>
    <albumId/>
    <album/>
    <albumArtURI/>
    <albumArtistId/>
    <albumArtist/>
    <genreId/>
    <genre/>
    <duration/>
    <canPlay/>
    <canSkip/>
    <canAddToFavorites/>
    <rating/>
    <trackNumber/>
    </trackMetadata>
    <streamMetadata></streamMetadata>
    </mediaMetadata>
    </getMetadataResult>
    </tns:getMetadataResponse>
    </soap:Body>
    </soap:Envelope>
  • getExtendedMetadata
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sonos.com/Services/1.1">
    <soap:Body>
    <tns:getExtendedMetadataResponse>
    <getExtendedMetadataResult>
    <mediaMetadata>
    <id>some_id_1</id>
    <title>Title 1</title>
    <mimeType>audio/mp4</mimeType>
    <itemType>track</itemType>
    <displayType>List</displayType>
    <summary>Summary text 1. Summary text 1. Summary text 1.</summary>
    <trackMetadata>
    <artistId/>
    <artist/>
    <composerId/>
    <composer/>
    <albumId/>
    <album/>
    <albumArtURI/>
    <albumArtistId/>
    <albumArtist/>
    <genreId/>
    <genre/>
    <duration/>
    <canPlay/>
    <canSkip/>
    <canAddToFavorites/>
    <rating/>
    <trackNumber/>
    </trackMetadata>
    <streamMetadata></streamMetadata>
    </mediaMetadata>
    </getExtendedMetadataResult>
    </tns:getExtendedMetadataResponse>
    </soap:Body>
    </soap:Envelope>
  • getMediaMetadata
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sonos.com/Services/1.1">
    <soap:Body>
    <tns:getMediaMetadataResponse>
    <getMediaMetadataResult>
    <id/>
    <title>Fake Track Title</title>
    <mimeType>audio/mp4</mimeType>
    <itemType>track</itemType>
    <displayType/>
    <summary/>
    <trackMetadata>
    <artistId>artist:12345</artistId>
    <artist>Bach</artist>
    <composerId/>
    <composer/>
    <albumId/>
    <album/>
    <albumArtURI>https://sonos.therocketfuel.com/images/istockphoto_1945235_satisfaction.jpg</albumArtURI>
    <albumArtistId/>
    <albumArtist/>
    <genreId/>
    <genre>Classical</genre>
    <duration>459</duration>
    <canPlay>true</canPlay>
    <canSkip>true</canSkip>
    <canAddToFavorites>false</canAddToFavorites>
    <rating/>
    <trackNumber/>
    </trackMetadata>
    <streamMetadata></streamMetadata>
    </getMediaMetadataResult>
    </tns:getMediaMetadataResponse>
    </soap:Body>
    </soap:Envelope>
  • getMediaURI
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sonos.com/Services/1.1">
    <soap:Body>
    <tns:getMediaURIResponse>
    <getMediaURIResult>https://sonos.therocketfuel.com/audio/960bpm.m4a</getMediaURIResult>
    </tns:getMediaURIResponse>
    </soap:Body>
    </soap:Envelope>
  • 最佳答案

    解决方案

    我终于弄明白了,基本上我的服务返回了有效的 XML,但这对于 WSDL 模式来说是不正确的。

    我使用 SoapUI 调试了这个如下:

  • 创建一个新的 SOAP 项目
  • 项目名称:随心所欲
  • 初始 WSDL:指向您的服务提供 WSDL 的位置
  • 检查“创建请求”和“创建测试套件”
  • 按住 Ctrl 键单击(右键单击)TestSteps 文件夹并单击“添加步骤”,然后选择“SOAP 请求”
  • 给它任何你喜欢的名字(我用过例如 actionName_validate)
  • 选择要验证的 SOAP 操作/操作
  • 确保勾选“添加架构断言(添加响应符合其架构的验证)”复选框,然后单击确定
  • 双击左侧列表中新创建的测试步骤并运行它(单击左上角的绿色播放按钮)
  • 如果您的服务响应符合 WSDL,您将在左下角看到一个绿色圆圈,上面写着“断言”。如果没有,它会是红色的,它会给你一个完整的列表,列出你的回答中的所有错误。
  • 一一修复您的架构中的任何问题,直到它变绿

  • 使用 Ruby 时的额外详细信息

    另外,这里有一些更多的细节可以帮助遇到这种情况的人,特别是如果你在 Ruby 中构建你的服务......

    Ruby 中围绕 SOAP 服务的工具不如 Java(甚至 PHP)。我正在使用 wash_out gem 虽然适用于全新的 SOAP 服务,但表达能力不足以让您定义与官方 Sonos WSDL 匹配的类型映射等。我也无法让它生成正确的 XML 响应(它错过了一个关键的 xmlns 所需的属性,或者不会命名所有元素。)

    我通过手动提供带有模板的 XML 响应来解决这个问题,因为这是最简单的方法。您可以使用 .xml.erb模板或使用 xml builder语法与 .xml.builder模板。确实,您可以以任何您想要的方式生成 XML,例如 to_xml或其他一些演示者类型库。

    对于 WSDL,我转而使用官方的 Sonos SMAPI WSDL,只需更改底部的服务地址,以指向我的服务提供修改后的 WSDL 的位置。

    关于Sonos 音乐 API 实现 "Unable to browse music"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35585961/

    38 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com