Object reference not set to an instance of an object

Object reference not set to an instance of an object

Hi Everybody,

I have found a UPnP Libraty UPnPLib (http://www.sbbi.net/site/upnp/) to discover and interact with UPnP Device. Now I am trying to Create a Object in Intel UPnP AV Server by using this library. But when I try to invoke CreateObject action by giving ContainerID and Elements in input I am getting back the following SOAP error.

xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">


s:Client
UPnPError

402
Argument [DIDL-Lite] : Object reference not set to an instance of an object.



I am using this DIDL-Lite file

xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">

Nothing Else Matters
object.item.audioItem.musicTrack
Metallica
UNKNOWN
importURI="http://192.168.0.199:60968/MediaServerContent_0/2/0000000000000007/">
http://192.168.0.199:60968/MediaServerContent_0/2/0000000000000007/Metal...
importURI="http://192.168.67.1:59616/MediaServerContent_0/2/0000000000000007/">
http://192.168.67.1:59616/MediaServerContent_0/2/0000000000000007/Metall...
Nice song of Metallica English
Metal

and the input parameter for ContainerID is 0000000000000005. If I use Intel Device Spy with this same ContainerID and DIDL-Lite description then the object creation is working properly. But from my Java Program this is not working.

I am also sending the Java Code . I appreciate if anybody can help me anyway.

package com.philips.research.my.test;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

import net.sbbi.upnp.Discovery;
import net.sbbi.upnp.devices.UPNPRootDevice;
import net.sbbi.upnp.messages.ActionMessage;
import net.sbbi.upnp.messages.ActionResponse;
import net.sbbi.upnp.messages.UPNPMessageFactory;
import net.sbbi.upnp.messages.UPNPResponseException;
import net.sbbi.upnp.services.UPNPService;

public class TestUPnPServer
{
public static void main(String[] args) {
new TestUPnPServer();
}

public TestUPnPServer()
{
try
{
String st = "urn:schemas-upnp-org:device:MediaServer:1";
UPNPRootDevice[] rootDevice = Discovery.discover(st);
if ( rootDevice != null )
{
for ( int i = 0; i < rootDevice.length; i++ ) {
System.out.println( "Found device "
+ rootDevice[i].getModelName());
}
}

File file = new
File("C:\Dump_Factory\RAClient\MetaData\DIDL.txt");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
StringBuffer body = new StringBuffer(256);
try
{
fis = new FileInputStream(file);
bis = new BufferedInputStream(f
is);
dis = new DataInputStream(bis);

while (dis.available() != 0) {
body.append(dis.readLine());
body.trimToSize();
}
// dispose all the resources after using them.
fis.close();
bis.close();
dis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(body);

/* FileInputStream f_in = new FileInputStream
("C:\Dump_Factory\RAClient\MetaData\MetaData.xml");
ObjectInputStream obj_in = new ObjectInputStream(f_in);
Object obj = obj_in.readObject ();
System.out.println(obj.toString());*/

String srvURN = "urn:schemas-upnp-org:service:ContentDirectory:1";
UPNPService contentDirectory = rootDevice[0].getService(srvURN);
//System.out.println(contentDirectory.getAvailableActionsName());
if (contentDirectory != null )
{
// System.out.println( "Service ID " +
// contentDirectory.getServiceId() );
UPNPMessageFactory factory =
UPNPMessageFactory.getNewInstance(contentDirectory);

ActionMessage action =
factory.getMessage("CreateObject");
&nbsp
;

/* ActionMessage action1 =
factory.getMessage( "DestroyObject" );

action1.setInputParameter
("ObjectID", "0000000000000006");
ActionResponse resp1 = action1.service();
*/
//System.out.println(resp1.toString());

if ( action != null ) {
// setting the input params
action.setInputParameter
("ContainerID", "0000000000000005");
action.setInputParameter
("Elements", body);

try
{
ActionResponse resp = action.service();
System.out.println(resp.getOutActionArgumentValue("ObjectID"));
System.out.println(resp.getOutActionArgumentValue("Result"));

} catch ( UPNPResponseException respEx )
{
respEx.printStackTrace();
} catch ( IOException ioEx ) {ioEx.printStackTrace();
}
}
}
} catch (Except
ion e) {
e.printStackTrace();

}
}
}

Best regards

Yeasin Habib

1 contenuto / 0 nuovi
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione