Invoking UPnP actions

大兔子大兔子 提交于 2019-12-13 04:00:30

问题


I'm attempting to interact with a UPnP printer on my network. I can discover the printer, get the available services on it, and even get the list of actions available for a service. However, this is where I'm stuck.

For example, there is an action GetPrinterAttributes and I know I need to create a http POST to send an envelop requesting the action, but I do no know what that looks like. I'm hoping someone can help point me to documentation or anything to get me going again.

Based on other examples, I tried creating the request payload as follows:

<s:Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:GetPrinterAttributes xmlns:u="urn.schemas-upnp-org:device:Printer:1">
        </u:GetPrinterAttributes>
    </s:Body>
</s:Envelope>

This is as far as I can get, yet I don't know what the tags mean. Hoping for some help there.

thanks!


回答1:


You really are implementing a UPnP control point from scratch :o . There must be usable UPnP libraries for your platform that would cut the amount of work needed to maybe 1-5%. But I guess you knew that so carry on... I just wanted to make sure you understand that UPnP is not the simplest protocol and implementing it for a single application makes little sense.

I'll just refer you to the same document as I did for SSDP: UDA 1.1 pdf, especially 3.1.1 SOAP Profile. You could read the actual SOAP spec as well, but I think the UPnP docs are complete enough. The UDA defines the SOAP profile and contains several envelope examples. It also explains what the containing HTTP POST must look like (see especially the required headers).

about your envelope (without having seen the Printer spec): GetPrinterAttributes namespace is wrong as methods are defined in a service, not device. It's also missing the initial <?xml version="1.0"> line.



来源:https://stackoverflow.com/questions/18972224/invoking-upnp-actions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!