Hello everybody,
I am trying to send the SOAP Request in attachment envs.xml to a Web
Service.
The code is the following:
...
urlC = new URL(
"http://localhost:8081/csw/services/CSW20_Manager_SOAP_Port");
System.out.println("urlC " + urlC);
EndpointReference targetEPR = new
EndpointReference(urlC.toString());
Options options = new Options();
options.setTo(targetEPR);
options.setAction("CSW-Publication.transaction");
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
String filePath =
"C:/hilbring/EclipseWTP/CATBMT2/gedanken/metadata/env.xml";
StAXOMBuilder parser = new
StAXOMBuilder(filePath);
System.out.println("SOAP Request");
System.out.println(parser.getDocumentElement());
sender.sendReceive(parser.getDocumentElement());
System.out.println("Finished");
This the SOAP Request I can see inside the tcpmon:
POST /csw/services/CSW20_Manager_SOAP_Port HTTP/1.1
SOAPAction: "CSW-Publication.transaction"
User-Agent: Axis2
Host: orchestra.iitb.fraunhofer.de:8081
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
2000
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Heade
r><wsa:To>http://localhost:8081/csw/services/CSW20_Manager_SOAP_Port</ws
a:To><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anon
ymous</wsa:Address></wsa:ReplyTo><wsa:MessageID>urn:uuid:60FAD0B9722E0DA
F8E11642694255516</wsa:MessageID><wsa:Action>CSW-Publication.transaction
</wsa:Action></soapenv:Header><soapenv:Body><soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Header />
<soapenv:Body>
<ns1:Transaction xmlns:ns1="http://www.opengis.net/cat/csw"
xmlns="http://www.opengis.net/cat/csw" requestId="csw:1011499216"
service="CSW" verboseResponse="false" version="2.0">
<ns1:Insert>
<ns1:MD_Metadata
xmlns:ns1="http://schemas.opengis.net/iso19115full">
...
</ns1:MD_Metadata>
</ns1:Insert>
</ns1:Transaction>
</soapenv:Body>
</soapenv:Envelope></soapenv:Body></soapenv:Envelope>
0
I receive the following exception:
org.apache.axis2.AxisFault: java.lang.ClassCastException:
org.apache.axis.message.Text
at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisO
peration.java:295)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:572
)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:503
)
I noticed that the Header contains several elements not included in my
original SOAP Request.
Then I tried to create the SOAP Envelope in the following way. The body
part is attached
in bodys.xml:
urlC = new URL(
"http://localhost:8081/csw/services/CSW20_Manager_SOAP_Port");
System.out.println("urlC " + urlC);
EndpointReference targetEPR = new
EndpointReference(urlC.toString());
Options options = new Options();
options.setTo(targetEPR);
options.setAction("CSW-Publication.transaction");
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
String filePath =
"C:/hilbring/EclipseWTP/CATBMT2/gedanken/metadata/body.xml";
StAXOMBuilder parser = new
StAXOMBuilder(filePath);
OMNamespaceImpl ns = new
OMNamespaceImpl("http://schemas.xmlsoap.org/soap/envelope/","soapenv");
SOAP11Factory factory = new SOAP11Factory();
SOAPEnvelope env = factory.createSOAPEnvelope();
SOAPHeader header = factory.createSOAPHeader();
env.addChild(header);
SOAP11BodyImpl body = new
SOAP11BodyImpl(env,factory);
body.addChild(parser.getDocumentElement());
env.addChild(body);
OMNamespaceImpl xsd = new
OMNamespaceImpl("http://www.w3.org/2001/XMLSchema","xsd");
OMNamespaceImpl xsins = new
OMNamespaceImpl("http://www.w3.org/2001/XMLSchema-instance","xsi");
env.setNamespace(xsd);
env.setNamespace(xsins );
env.setNamespace(ns);
System.out.println("SOAP Request");
System.out.println(env.toString());
sender.sendReceive(env);
System.out.println("Finished");
and receive the following error:
23.11.2006 09:20:54
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (org.apache.axis2.AxisFault) caught when processing
request: Can not output XML declaration, after other output has already
been done.; nested exception is:
javax.xml.stream.XMLStreamException: Can not output XML
declaration, after other output has already been done.
The SOAP Request in tcpmon is empty:
POST /csw/services/CSW20_Manager_SOAP_Port HTTP/1.1
SOAPAction: "CSW-Publication.transaction"
User-Agent: Axis2
Host: orchestra.iitb.fraunhofer.de:8081
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
What is wrong?
Thanks for any help,
best regards,
Desiree
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope">
<ns1:Transaction requestId="csw:1011499216" service="CSW"
verboseResponse="false" version="2.0" xmlns="http://www.opengis.net/cat/csw"
xmlns:ns1="http://www.opengis.net/cat/csw">
<ns1:Insert>
<ns1:MD_Metadata
xmlns:ns1="http://schemas.opengis.net/iso19115full">
...
</ns1:MD_Metadata>
</ns1:Insert>
</ns1:Transaction>
</soapenv:Body><soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header />
<soapenv:Body>
<ns1:Transaction xmlns:ns1="http://www.opengis.net/cat/csw"
xmlns="http://www.opengis.net/cat/csw" requestId="csw:1011499216" service="CSW"
verboseResponse="false" version="2.0">
<ns1:Insert>
<ns1:MD_Metadata
xmlns:ns1="http://schemas.opengis.net/iso19115full">
...
</ns1:MD_Metadata>
</ns1:Insert>
</ns1:Transaction>
</soapenv:Body>
</soapenv:Envelope>---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]