Problems with code execution on Mobile devices

  • Thread starter Thread starter Robert Iver
  • Start date Start date
R

Robert Iver

Hello fellow developers,

I'm hoping someone out there can steer me down the right path
with this little conundrum I have, because I am getting frustrated more
and more by the minute. I have a feeling it has something to do with
security/authentication, but I don't know where to start on tackling
it. Here's my scenario:

I'm writing a app that will go onto Pocket PC devices (v2003
SE) that will allow members of our sales team to look up information on
items and run reports. One of the requirements is that they have to be
able to print out those reports after they run them, and they can't lug
printers around with them everywhere. So, I started writing a
webservice with a couple of different methods that would allow the
sales team to select a computer, and then based on their selection,
select a printer to print to.

I'm using the System.DirectoryServices namespace to get a list
of computers from the Sales OU and then populate my combo box for the
sales people to select from. Then I'm using the System.Management
namespace to get all the printers attached to that computer.

Well, it's not working....in my attempts to fix the problem, I
built a VERY simple Windows app that simply takes the webservice code
and runs it locally and it works perfectly.

The problem comes when I'm trying to run the
webservice.....I've posted the code for the webservice below, so feel
free to look at it and see if you can figure out what's going on. Let
me know if you have questions....

<code>
[WebMethod]
public String[] GetComputers(String[] OrganizationalUnits) {
String[] finishedArrayofStrings = null;
DirectoryEntry searchRoot = null;
DirectorySearcher searchForComputers = null; // all null so
can access inside foreach loops
SearchResultCollection searchResults = null;

foreach(String ou in OrganizationalUnits) {

searchRoot = new DirectoryEntry("LDAP://OU=" + ou +
",DC=<basedomainname>,DC=com", "username", "password",
AuthenticationTypes.Secure);
searchForComputers = new DirectorySearcher(searchRoot);
searchForComputers.Filter =
"(&(objectCategory=computer)(name=*))";
searchResults = searchForComputers.FindAll();

foreach(SearchResult s in searchResults){
String temp_string = s.Path.ToString();
String[] temp_string_array = temp_string.Split(',');
// grab just the computer name and leave off the rest
_computerNames.Add(temp_string_array[0].Substring(10,
(int)temp_string_array[0].Length - 10));
}

}

int i = 0;
finishedArrayofStrings = new String[_computerNames.Count];
while (i <= _computerNames.Count) {
finishedArrayofStrings = _computerNames.ToString();
i++;
}

return finishedArrayofStrings;
</code>
 
What does "not working" mean? Does it throw an error
or does the web method just not return anything?

If you are debugging, you should be able to step through
the web method call while also stepping through your
ppc code.

Not to insult your intelligence but if you don't know
how to debug web methods, just launch the web
service in your browser via debug mode in visual studio.

Put a break point in this method. When the pocket pc
app calls the web service, visual studio will pick it up
and let you step through it.


--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp





Robert Iver said:
Hello fellow developers,

I'm hoping someone out there can steer me down the right path
with this little conundrum I have, because I am getting frustrated more
and more by the minute. I have a feeling it has something to do with
security/authentication, but I don't know where to start on tackling
it. Here's my scenario:

I'm writing a app that will go onto Pocket PC devices (v2003
SE) that will allow members of our sales team to look up information on
items and run reports. One of the requirements is that they have to be
able to print out those reports after they run them, and they can't lug
printers around with them everywhere. So, I started writing a
webservice with a couple of different methods that would allow the
sales team to select a computer, and then based on their selection,
select a printer to print to.

I'm using the System.DirectoryServices namespace to get a list
of computers from the Sales OU and then populate my combo box for the
sales people to select from. Then I'm using the System.Management
namespace to get all the printers attached to that computer.

Well, it's not working....in my attempts to fix the problem, I
built a VERY simple Windows app that simply takes the webservice code
and runs it locally and it works perfectly.

The problem comes when I'm trying to run the
webservice.....I've posted the code for the webservice below, so feel
free to look at it and see if you can figure out what's going on. Let
me know if you have questions....

<code>
[WebMethod]
public String[] GetComputers(String[] OrganizationalUnits) {
String[] finishedArrayofStrings = null;
DirectoryEntry searchRoot = null;
DirectorySearcher searchForComputers = null; // all null so
can access inside foreach loops
SearchResultCollection searchResults = null;

foreach(String ou in OrganizationalUnits) {

searchRoot = new DirectoryEntry("LDAP://OU=" + ou +
",DC=<basedomainname>,DC=com", "username", "password",
AuthenticationTypes.Secure);
searchForComputers = new DirectorySearcher(searchRoot);
searchForComputers.Filter =
"(&(objectCategory=computer)(name=*))";
searchResults = searchForComputers.FindAll();

foreach(SearchResult s in searchResults){
String temp_string = s.Path.ToString();
String[] temp_string_array = temp_string.Split(',');
// grab just the computer name and leave off the rest
_computerNames.Add(temp_string_array[0].Substring(10,
(int)temp_string_array[0].Length - 10));
}

}

int i = 0;
finishedArrayofStrings = new String[_computerNames.Count];
while (i <= _computerNames.Count) {
finishedArrayofStrings = _computerNames.ToString();
i++;
}

return finishedArrayofStrings;
</code>
 
"not working" means that it throws an unhandled Web Exception and then
that's all she wrote. The inner Exception message says that "A
connection could not be established because the target machine actively
refused it.

Some of the suggested fixes out there have told me to look at the
firewall, but I have no firewall between my machine and the machine the
webservice is running on.

I will continue to try to find a solution, but at this point I am at a
loss.

What does "not working" mean? Does it throw an error
or does the web method just not return anything?

If you are debugging, you should be able to step through
the web method call while also stepping through your
ppc code.

Not to insult your intelligence but if you don't know
how to debug web methods, just launch the web
service in your browser via debug mode in visual studio.

Put a break point in this method. When the pocket pc
app calls the web service, visual studio will pick it up
and let you step through it.


--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp





Robert Iver said:
Hello fellow developers,

I'm hoping someone out there can steer me down the right path
with this little conundrum I have, because I am getting frustrated more
and more by the minute. I have a feeling it has something to do with
security/authentication, but I don't know where to start on tackling
it. Here's my scenario:

I'm writing a app that will go onto Pocket PC devices (v2003
SE) that will allow members of our sales team to look up information on
items and run reports. One of the requirements is that they have to be
able to print out those reports after they run them, and they can't lug
printers around with them everywhere. So, I started writing a
webservice with a couple of different methods that would allow the
sales team to select a computer, and then based on their selection,
select a printer to print to.

I'm using the System.DirectoryServices namespace to get a list
of computers from the Sales OU and then populate my combo box for the
sales people to select from. Then I'm using the System.Management
namespace to get all the printers attached to that computer.

Well, it's not working....in my attempts to fix the problem, I
built a VERY simple Windows app that simply takes the webservice code
and runs it locally and it works perfectly.

The problem comes when I'm trying to run the
webservice.....I've posted the code for the webservice below, so feel
free to look at it and see if you can figure out what's going on. Let
me know if you have questions....

<code>
[WebMethod]
public String[] GetComputers(String[] OrganizationalUnits) {
String[] finishedArrayofStrings = null;
DirectoryEntry searchRoot = null;
DirectorySearcher searchForComputers = null; // all null so
can access inside foreach loops
SearchResultCollection searchResults = null;

foreach(String ou in OrganizationalUnits) {

searchRoot = new DirectoryEntry("LDAP://OU=" + ou +
",DC=<basedomainname>,DC=com", "username", "password",
AuthenticationTypes.Secure);
searchForComputers = new DirectorySearcher(searchRoot);
searchForComputers.Filter =
"(&(objectCategory=computer)(name=*))";
searchResults = searchForComputers.FindAll();

foreach(SearchResult s in searchResults){
String temp_string = s.Path.ToString();
String[] temp_string_array = temp_string.Split(',');
// grab just the computer name and leave off the rest
_computerNames.Add(temp_string_array[0].Substring(10,
(int)temp_string_array[0].Length - 10));
}

}

int i = 0;
finishedArrayofStrings = new String[_computerNames.Count];
while (i <= _computerNames.Count) {
finishedArrayofStrings = _computerNames.ToString();
i++;
}

return finishedArrayofStrings;
</code>
 
Back
Top