2012-05-29 80 views
0

我試圖在UPnP中使用soap調用事件。我從網絡中嗅出了這個命令,我想重現這一點,但我不知道從哪裏開始+我應該使用哪個「框架/庫」。Java:爲UPnP重新創建SOAP請求

任何建議,以在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> 

回答

0

具體申請是DimmableLight DCP的調用,因爲我已經回答了你在這裏

UPnP: intel: generate stack: java android: invoking actions on network light sample

是的,它是SOAP。儘管使用一些通用的SOAP工具集來重現它是絕對有可能的,但它不會讓你感覺到任何地方。要實際發送請求,您需要知道DimmableLight設備在哪個插座上公開其DCP。這意味着控制點(您繁瑣地嘗試複製的請求的來源)必須收聽來自UPnP網絡的NOTIFY數據包。 SOAP不會幫助你。

我推薦閱讀由@simonc提到的文檔包中的UPnP-arch-DeviceArchitecture,以便在跳過再現某些隨機嗅探數據包之前知道UPnP是如何工作的。然後使用一個現成的庫。我不能說Java,但C++ Platinum加載了可以理解的例子。 UPnP僅僅是一個有據可查的已知和廣泛技術的融合。