cancel
Showing results for 
Search instead for 
Did you mean: 

Debug web service in NWDS?

Former Member
0 Kudos

Hi,

I am getting a nil string when I test web service, I see this in the NWDS (web services checker):

getOfficeListResponse

response

Here is my web service method:

public String[] getOfficeList(String userID){

try {

IUser user = UMFactory.getUserFactory().getUser(userID);

String[] listOfGroups = null;

int length = 0;

Iterator iterator = user.getParentGroups(true);

while(iterator.hasNext()){

listOfGroupslength = iterator.next().toString();

length++;

}

if(length == 0)

return null;

else

return listOfGroups;

} catch (UMException e) {

// TODO Auto-generated catch block

// e.printStackTrace();

return null;

}

}

Any bug in the code?

Can anybody let me know how to debug a web service method?

Thanks a lot!

Tony

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

I used a program called WebServiceStudio 2.0 to debug my web

services. You can set your breakpoints, run the debugger and then launch this

program that will send a SOAP or HTTP request to your web service. Doing this

will hit your breakpoints so you can debug. More information on the program

can be found here:

Former Member
0 Kudos

When you are ready to build and run your Web service, you must first compile the ASP.NET Web Service project. Once compiled, you can run the Web service. For more information, see Debugging Preparation: ASP.NET Web Service Projects.

You can choose from three methods to build and run your Web service:

Method

Description

With the debugger

This method starts the default browser and loads the specified start page. Running a page in the debugger makes it possible for you to step through code line-by-line and use additional analysis tools and runtime information. If Visual Studio detects that key files have changed, it will also build the project before launching the browser with the specified start page.

Without the debugger

This method makes it possible for you to run your code as it normally would run outside of the context of development tools, and therefore no runtime information is available through these tools. If Visual Studio detects that key files have changed, it will build the project before launching the browser with the specified start page. However, you can attach the debugger to the process as needed.

View in browser

This method compiles the project and opens a Web page chosen from Solution Explorer. Visual Studio compiles and runs the project in the default browser within Visual Studio.

To build and run a Web service with the debugger

In Solution Explorer, right-click the .asmx file for the Web service you wish to run and click Set As Start Page on the shortcut menu.

On the Debug menu, click Start.

This command instructs Visual Studio to run the Web service in the debugger.

To stop running the form and return to the Code Editor, close the browser, or click Stop Debugging on the Debug menu.

To build and run a Web service without the debugger

In Solution Explorer, right-click the .asmx file for the Web service you wish to run and click Set As Start Page on the shortcut menu.

On the Debug menu, click Start Without Debugging.

Visual Studio saves all files in the project and then builds it. Once built, Visual Studio launches the default browser and navigates to the project's start page.

To stop running the Web service and return to the Code Editor, close the browser.

To build and run a Web service using the View in Browser option

In Solution Explorer, right-click the .asmx file for the Web service you want to run and click View in Browser on the shortcut menu.

Visual Studio builds the Web service and launches the specified start page within the IDE.

To stop running the Web service and return to the Code Editor, close the browser.

Former Member
0 Kudos

Hi Tony,

In your code, the problem is occuring due to the below line:

String[] listOfGroups = null;

As the String array is defined as a NULL object, the code in the while loop, where you assign values to this array should be throwing out an exception.

You need to initialise the String array with some specified length. it can be done as:

String[10] listOfGroups = {};

Also, while doing the exception handling, you have returned NULL in case of occurrence of an exception. A better approach will be to return the exception message or stacktrace.

Regards,

Alka.

Former Member
0 Kudos

Hi Tony,

Have a look at the following blog:

/people/sap.user72/blog/2004/12/17/some-handy-http-tools

Regards.

Rajat