Tony

The URL you are using is not a SOAP endpoint URL.

Maybe that is what is wrong!?

Paul

On 11/12/06, Tony Fang <[EMAIL PROTECTED]> wrote:
Hi, there.

I always get the exception like "org.apache.axis2.AxisFault: Can not output
XML declaration, after other output has already been done.; nested exception
is: " when I try to run the following code. Does some one also meet this
AxisFault before?

you can find the Web Service here, both WSDL file, and SOAP Request and
Response sample. (I am sure, I can get the response when I using Axis1.1)

Any commonts would help me.

Thanks
Tony

---- Flowing the test code ----------------



package tony.axis.test;

import org.apache.axiom.om.*;
import org.apache.axiom.soap.*;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.* ;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.MessageContextConstants;
import org.apache.axis2.client.async.*;

public class SoapTest2 {

 public static void main(String[] args) {

  //String url =
"http://www.xignite.com/xFutures.asmx/GetFutureSymbol";;
  String url ="
http://www.xignite.com/services/GetFutureSymbol";;

  Options options = new Options();

//options.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
  options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
  options.setTo(new EndpointReference(url));


  try {
   ServiceClient serviceClient = new ServiceClient();
   serviceClient.setOptions(options);
   SOAPFactory omFactory =
OMAbstractFactory.getSOAP11Factory();
         SOAPEnvelope envelope = omFactory.getDefaultEnvelope ();
   OMNamespace xsi =
omFactory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance";,
"xsi");
   OMNamespace xsd = omFactory.createOMNamespace
("http://www.w3.org/2001/XMLSchema";, "xsd");
   OMNamespace soap = omFactory.createOMNamespace("
http://schemas.xmlsoap.org/soap/envelope/";, "soap");
   OMNamespace defNs =
omFactory.createOMNamespace("http://www.xignite.com/services/";,
"");
   OMNamespace nullNs = omFactory.createOMNamespace("", "");

   OMElement operation =
                omFactory.createOMElement("GetFutureSymbol",
                        "",
                        "");
   operation.setNamespace(defNs);

   SOAPHeader header = envelope.getHeader();
   SOAPBody body = envelope.getBody();
   body.addChild(operation);

   envelope.setNamespace(xsi);
   envelope.setNamespace(xsd);
   envelope.setNamespace(soap);

   OMElement username = omFactory.createOMElement("Username", nullNs);
   username.setText("");
   header.addChild(username);
   OMElement password = omFactory.createOMElement("Password", nullNs);
   password.setText("");
   header.addChild(password);
   OMElement tracer = omFactory.createOMElement("Tracer", nullNs);
   tracer.setText("");
   header.addChild(tracer);
   OMElement symbol = omFactory.createOMElement("Symbol", nullNs);
   symbol.setText("CL");
   operation.addChild(symbol);
   OMElement month = omFactory.createOMElement("Month", nullNs);
   month.setText("9");
   operation.addChild(month);
   OMElement year = omFactory.createOMElement("Year", nullNs);
   year.setText("2002");
   operation.addChild(year);

   System.out.println(envelope);
   OMElement result = serviceClient.sendReceive(envelope);
   System.out.print(result);

  } catch (AxisFault e1) {
   System.out.println("AxisFault");
   System.out.println(e1.getFaultRole());
   e1.printStackTrace();
  }
 }
}



--
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair

http://bloglines.com/blog/paulfremantle
[EMAIL PROTECTED]

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to