0

我正在尝试在 UPnP 中使用肥皂调用事件。我从网络上嗅到了这个命令,我想重现它,但我不知道从哪里开始 + 我应该使用哪个“框架/lib”。

有什么建议可以在java中完成吗?

此代码需要复制:

POST /_urn-upnp-org-serviceId-SwitchPower.0001_control HTTP/1.1
SOAPACTION: "urn:schemas-upnp-org:service:SwitchPower:1#SetTarget"
CONTENT-TYPE: text/xml; charset="utf-8"
HOST: 192.168.1.18:1451
Content-Length: 347

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"      xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
  <u:SetTarget xmlns:u="urn:schemas-upnp-org:service:SwitchPower:1">
     <newTargetValue>0</newTargetValue>
  </u:SetTarget>
</s:Body>
</s:Envelope>HTTP/1.1 200 OK
EXT: 
CONTENT-TYPE: text/xml; charset="utf-8"
SERVER: Windows NT/5.0, UPnP/1.0
Content-Length: 290

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"     xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <u:SetTargetResponse xmlns:u="urn:schemas-upnp-org:service:SwitchPower:1" />
  </s:Body>
</s:Envelope>
4

1 回答 1

0

具体来说,这个请求是对 DimmableLight DCP 的调用,因为我已经在这里回答了你

UPnP:intel:生成堆栈:java android:在网络灯样本上调用操作

是的,它是 SOAP。虽然使用一些通用 SOAP 工具集复制它是绝对可能的,但它不会让您有任何收获。要实际发送请求,您需要知道 DimmableLight 设备在哪个套接字上公开其 DCP。这意味着控制点(您正在繁琐地尝试重现的请求的来源)必须侦听来自 UPnP 网络的 NOTIFY 数据包。SOAP 不会帮助你。

我建议从@simonc 提到的文档包中阅读 UPnP-arch-DeviceArchitecture,以便您了解 UPnP 的工作原理,然后再开始复制一些随机嗅探的数据包。然后使用现成的库之一。我不能为 Java 说话,但 C++ Platinum 中有很多可以理解的例子。UPnP 只是一个有据可查的已知和广泛技术的合并。

于 2012-05-29T12:55:54.293 回答