Upnp가 활성화 된 TV로 명령을 보내고 놀았습니다. 네트워크에서 UPNP 장치를 요청한 다음 tv를 통해 명령을 보내려면 C# 코드를 작성했습니다. 그러나 TV에 요청할 때 400 개의 잘못된 요청이 계속됩니다. 나는 Fiddler에서 봤고 이것은 RAW 요청 인 것 같다.UPnP TV에 비누 전화 요청이 잘못되었습니다.
POST http://192.168.1.4:52323/upnp/control/RenderingControl HTTP/1.1 SOAPACTION: urn:schemas-upnp-org:service:RenderingControl:1#SetVolume Content-Type: text/xml;charset="utf-8" Accept: text/xml Host:
192.168.1.4:52323 Content-Length: 418 Expect: 100-continue Connection: Keep-Alive
<?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>
<ns0:SetVolume xmlns:ns0="urn:schemas-upnp-org:service:RenderingControl:1">
<InstanceId>0</InstanceId>
<Channel>Master</Channel>
<DesiredVolume>70</DesiredVolume>
</ns0:SetVolume> </s:Body> </s:Envelope>
누구나이 요청에 나쁜 점이 있습니까? 여기
내가 C 번호에 WebRequest 클래스를 구성하고있어 어떻게 : 나는 전혀 코드를 제거하고 단지 피들러를 통해 요청을 형성하기 위해 노력했습니다
을
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Headers.Add("SOAPACTION", action);
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
업데이트되었습니다. 현재 라우터에 TV를 연결하지 않았으므로 라우터에 전화를 걸려고합니다. 이 피들러를 통해 내 새로 건설 된 전화입니다 :
내가 잘못된 행동 repsones, 또는 예를 들어 나쁜 XML 중 하나가 계속하지만POST http://10.0.0.1:49153/upnp/control/Layer3Forwarding HTTP/1.1
SOAPACTION: urn:schemas-upnp-org:service:Layer3Forwarding:1#GetDefaultConnectionService
Content-Type: text/xml;charset="utf-8"
Host: 10.0.0.1:49153
Content-Length: 345
<?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>
<ns0:GetDefaultConnectionService xmlns:ns0="urn:schemas-upnp-org:service:Layer3Forwarding:1">
</ns0:GetDefaultConnectionService>
</s:Body>
</s:Envelope>
아래에이 응답 :
HTTP/1.1 500 Internal Server Error
CONTENT-LENGTH: 413
CONTENT-TYPE: text/xml; charset="utf-8"
DATE: Tue, 14 Mar 2017 21:55:49 GMT
EXT:
SERVER: Linux/3.12.14, UPnP/1.0, Portable SDK for UPnP devices/1.6.18
X-User-Agent: redsonic
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring>UPnPError</faultstring>
<detail>
<UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
<errorCode>-111</errorCode>
<errorDescription>Invalid Action</errorDescription>
</UPnPError>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
내 요청이 실패 할 수 방법에 대한 아이디어 ?
POST 라인에서'control/Layer3Forwarding'을'Layer3Forwarding/control'으로 교체하는 것은 어떨까요? 내 장치에서 어떻게 보이는지. –
조언을 주셔서 감사합니다, 내 문제는 내 SOAPACTION 따옴표가 아니라고 생각합니다. 나는 지금 바이올린으로 반응을 얻고있는 것 같습니다. Device Spy는 내 요청과 올바른 형식의 요청 간의 차이를 추적하는 데 큰 도움이되었습니다. – user1496741