You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by "Beer, Christian" <BE...@DIRON.de> on 2002/02/14 11:43:44 UTC

How can I unmarshall an Envelope and a Fault?

Hi Folks!

I am writing a web-service and it's client. It shall communicate
using messages.

Now, If the call is successful, I get "text/plain" - ok.

If an error occurs I get "text/xml" and then it's an Envelope.
I thried:

      // SOAP-Error
      BufferedReader rdr = soapTrans.receive();
      StringBuffer  sbuf = new StringBuffer(65535);
      String s;
      while ((s = rdr.readLine()) != null) {
        System.out.println(s);
        sbuf.append(s);
      }

      Document  soapEnv = db.parse(new InputSource(new ByteArrayInputStream(
                                   sbuf.toString().getBytes())));

      Element   envElm  = soapEnv.getDocumentElement();
      Envelope  env   = Envelope.unmarshall(envElm,
soapTrans.getResponseSOAPContext());
      Body      bdy   = env.getBody();
      Fault     fault = new Fault();
      Vector elmts = bdy.getBodyEntries();
      fault.unmarshall(null, (Node)elmts.get(0), new SOAPMappingRegistry(), 
                       msg.getResponseSOAPContext());

      return "ERR " + fault.getFaultString();

but that gives:
java.lang.IllegalArgumentException: Root element of a SOAP message must be:
'http://schemas.xmlsoap.org/soap/envelope/:Envelope'.
	at org.apache.soap.Envelope.unmarshall(Envelope.java:306)
	at
de.diron.postag.mailingfactory.email.accesslayer.ECConnectorServiceStub.crea
teCampaign(ECConnectorServiceStub.java:130)
	at
de.diron.postag.mailingfactory.email.accesslayer.test.Test.main(Test.java:70
)

But it is an Envelope!! I checked that.

What can I do??

Christian Beer

____________________________________________________
DIRON Wirtschaftsinformatik GmbH & Co. KG
Christian Beer          (Christian.Beer@diron.de)
Daimlerweg 39-41        Tel. : +49(251)979-200
48163 Muenster          Fax  : +49(251)979-2020
Germany                 Email: info@diron.de