All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cybergarage.upnp.control.ActionResponse Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
/******************************************************************
*
*	CyberUPnP for Java
*
*	Copyright (C) Satoshi Konno 2002
*
*	File: ActionResponse.java
*
*	Revision;
*
*	01/29/03
*		- first revision.
*	09/02/03
*		- Giordano Sassaroli 
*		- Problem : Action Responses do not contain the mandatory header field EXT
*		- Error : ActionResponse class does not set the EXT header
*	
******************************************************************/

package org.cybergarage.upnp.control;

import org.cybergarage.upnp.*;
import org.cybergarage.http.*;
import org.cybergarage.soap.*;
import org.cybergarage.xml.*;

public class ActionResponse extends ControlResponse
{
	////////////////////////////////////////////////
	//	Constructor
	////////////////////////////////////////////////
	
	public ActionResponse()
	{
		setHeader(HTTP.EXT, "");
	}

	public ActionResponse(SOAPResponse soapRes)
	{
		super(soapRes);
		setHeader(HTTP.EXT, "");
	}


	////////////////////////////////////////////////
	//	Response
	////////////////////////////////////////////////

	public void setResponse(Action action)
	{
		setStatusCode(HTTPStatus.OK);
	
		Node bodyNode = getBodyNode();
		Node resNode = createResponseNode(action);
		bodyNode.addNode(resNode);

		Node envNode = getEnvelopeNode();
		setContent(envNode);
	}

	private Node createResponseNode(Action action)
	{
		String actionName = action.getName();
		Node actionNameResNode = new Node(SOAP.METHODNS + SOAP.DELIM + actionName + SOAP.RESPONSE);
		
		Service service = action.getService();
		if (service != null) {
			actionNameResNode.setAttribute(
				"xmlns:" + SOAP.METHODNS,
					service.getServiceType());
		}
		
		ArgumentList argList = action.getArgumentList();
		int nArgs = argList.size();
		for (int n=0; n




© 2015 - 2024 Weber Informatics LLC | Privacy Policy