I'm using jax-ws 2.2.7 to produce a web service. The operation signature is:
#WebMethod
#RequestWrapper(localName = "setInvocationAddress", targetNamespace = "http://services.choreos.org/", className = "org.choreos.services.SetInvocationAddress")
#ResponseWrapper(localName = "setInvocationAddressResponse", targetNamespace = "http://services.choreos.org/", className = "org.choreos.services.SetInvocationAddressResponse")
#Action(input = "http://services.choreos.org/ShopEntrance/setInvocationAddressRequest", output = "http://services.choreos.org/ShopEntrance/setInvocationAddressResponse")
public void setInvocationAddress(
#WebParam(name = "arg0", targetNamespace = "") String arg0,
#WebParam(name = "arg1", targetNamespace = "") String arg1,
#WebParam(name = "arg2", targetNamespace = "") List<String> arg2);
This web service is running on Tomcat 6 with java 7.
I have sent the following SOAP message to it:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pre="http://services.choreos.org/">
<SOAP-ENV:Body>
<pre:setInvocationAddress>
<arg0>CD-shopentrance-marketingapplication</arg0>
<arg1>marketingapplication</arg1>
<arg2>http://localhost:8080/marketingapplication/marketingapplication</arg2>
</pre:setInvocationAddress>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In localhost environment it works. But not in production.
When things did not work, I got the following stack trace at the server side (tomcat log):
May 24, 2015 11:29:04 PM com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit handle
SEVERE: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:317)
at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:344)
at com.sun.xml.ws.transport.http.HttpAdapter.access$400(HttpAdapter.java:100)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:634)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:264)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:218)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.xml.ws.streaming.XMLStreamReaderException: XML reader error: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.wrapException(XMLStreamReaderUtil.java:326)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:99)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.nextContent(XMLStreamReaderUtil.java:169)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.nextElementContent(XMLStreamReaderUtil.java:104)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:202)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:338)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:156)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:312)
... 22 more
Caused by: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:464)
at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3058)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2941)
at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2078)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2058)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1117)
at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:96)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:80)
... 28 more
Someone has some idea of what happens?
Tks!!!
As the exception says, you cannot have blank target namespace.
It should be:
#WebParam(name = "arg0", targetNamespace = "http://services.choreos.org/")
Seems like JAX-WS generated the wrong annotation or you have some problem with your WSDL/XSD.
Related
I'm using jaxb2-marshaller to generate classes to communicate with a webservice. Java-classes are generated with use of wsdl files.
I consume some operations without problems, but with one in a specific scenario where the response don't has the namespace on the tag.
For one operation i got the response like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.xxx.xxx/xxxxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<outputType>
<test>1</test>
</outputType>
</soapenv:Body>
</soapenv:Envelope>
And i call it with WebServiceTemplate from springframework
public int test(String command) throws Exception {
InputType input = new InputType();
input.setCommandName(command);
ObjectFactory objFactory = new ObjectFactory();
JAXBElement<InputType> jaxbData = objFactory.createSendRemoteComand(input);
JAXBElement<OutputType> response = (JAXBElement<OutputType>) getWebServiceTemplate()
.marshalSendAndReceive(jaxbData);
return response.getValue().getTest();
}
And i receive the stack error below because the XML "outputType" don't have the namespace like "tns:outputType", i discovery it mocking response in SOAP UI.
javax.xml.bind.UnmarshalException: elemento inesperado (uri:"", local:"outputType").
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:247) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:242) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:109) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1131) ~[na:1.8.0_131]
Would anyone know a way to deal with the problem?
Is there any way one could get the sample request xml using the wsdl(url) alone?
Here is a sample wsdl: http://www.webservicemart.com/uszip.asmx?WSDL
Sample Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://webservicemart.com/ws/">
<soapenv:Header/>
<soapenv:Body>
<ws:ValidateZip>
<!--Optional:-->
<ws:ZipCode>?</ws:ZipCode>
</ws:ValidateZip>
</soapenv:Body>
</soapenv:Envelope>
I know there are tools out there like SOAPUI and others which could do this. But is there any other way without using these tools once could achieve it using java?
Using wsimport would be one option that would get me the java source, this is more static. Is there a dynamic way to do this?
Exception encountered:
18:57:59,677 WARN [SoapUI] Missing folder [D:\TestAutomation\Z_ZZLastResort\.\ext] for external libraries
18:57:59,920 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Users\mike\soapui-settings.xml]
Progress: 1 - Caching Definition from url [http://www.webservicemart.com/uszip.asmx?WSDL]
18:58:00,587 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/xop.xsd with targetNamespace http://www.w3.org/2004/08/xop/include
18:58:00,625 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/XMLSchema.xsd with targetNamespace http://www.w3.org/2001/XMLSchema
18:58:00,627 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/xml.xsd with targetNamespace http://www.w3.org/XML/1998/namespace
18:58:00,628 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/swaref.xsd with targetNamespace http://ws-i.org/profiles/basic/1.1/xsd
18:58:00,629 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/xmime200505.xsd with targetNamespace http://www.w3.org/2005/05/xmlmime
18:58:00,637 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/xmime200411.xsd with targetNamespace http://www.w3.org/2004/11/xmlmime
18:58:00,638 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/soapEnvelope.xsd with targetNamespace http://schemas.xmlsoap.org/soap/envelope/
18:58:00,641 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/soapEncoding.xsd with targetNamespace http://schemas.xmlsoap.org/soap/encoding/
18:58:00,643 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/soapEnvelope12.xsd with targetNamespace http://www.w3.org/2003/05/soap-envelope
18:58:00,645 INFO [SchemaUtils] Added default schema from file:/C:/Users/mike/Desktop/soapui-4.5.1-SNAPSHOT.jar!/com/eviware/soapui/resources/xsds/soapEncoding12.xsd with targetNamespace http://www.w3.org/2003/05/soap-encoding
Progress: 2 - Loading [http://www.webservicemart.com/uszip.asmx?WSDL]
18:58:00,648 DEBUG [WsdlLoader] Getting wsdl component from [http://www.webservicemart.com/uszip.asmx?WSDL]
18:58:01,073 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
18:58:01,074 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: GET /uszip.asmx?WSDL HTTP/1.1
18:58:01,314 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Connection closed
18:58:01,314 DEBUG [HttpClientSupport$SoapUIHttpClient] Closing the connection.
18:58:01,314 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Connection closed
18:58:01,314 INFO [HttpClientSupport$SoapUIHttpClient] I/O exception (java.net.SocketException) caught when processing request: Connection reset
18:58:01,316 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:110)
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:264)
at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$SoapUIHttpRequestExecutor.doReceiveResponse(HttpClientSupport.java:133)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:633)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:454)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader$LoaderWorker.construct(UrlWsdlLoader.java:226)
at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader.load(UrlWsdlLoader.java:138)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:121)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:535)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:524)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
at java.lang.Thread.run(Unknown Source)
18:58:01,319 INFO [HttpClientSupport$SoapUIHttpClient] Retrying request
18:58:01,319 DEBUG [HttpClientSupport$SoapUIHttpClient] Reopening the direct connection.
18:58:01,602 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 2 to execute request
18:58:01,602 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: GET /uszip.asmx?WSDL HTTP/1.1
18:58:02,200 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
18:58:02,210 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
Progress: 1 - Loading Definition from url
18:58:02,260 DEBUG [AbstractDefinitionContext] Loading Definition...
18:58:02,277 DEBUG [WsdlInterfaceDefinition] Loading WSDL: http://www.webservicemart.com/uszip.asmx?WSDL
18:58:02,277 DEBUG [AbstractWsdlDefinitionLoader] Returning baseInputSource [http://www.webservicemart.com/uszip.asmx?WSDL]
Retrieving document at 'http://www.webservicemart.com/uszip.asmx?WSDL'.
18:58:02,347 INFO [SchemaUtils] Loading schema types from [http://www.webservicemart.com/uszip.asmx?WSDL]
18:58:02,347 INFO [SchemaUtils] Getting schema http://www.webservicemart.com/uszip.asmx?WSDL
18:58:02,357 ERROR [SoapUI] An error occured [org.apache.xmlbeans.impl.xb.xsdschema.impl.SchemaDocumentImpl], see error log for details
java.lang.ArrayStoreException: org.apache.xmlbeans.impl.xb.xsdschema.impl.SchemaDocumentImpl
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getSchemas(SchemaUtils.java:418)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getSchemas(SchemaUtils.java:327)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.loadSchemaTypes(SchemaUtils.java:192)
at com.eviware.soapui.impl.support.definition.support.XmlSchemaBasedInterfaceDefinition.loadSchemaTypes(XmlSchemaBasedInterfaceDefinition.java:79)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlInterfaceDefinition.load(WsdlInterfaceDefinition.java:61)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:66)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:30)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:268)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.access$400(AbstractDefinitionContext.java:44)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:235)
at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
at java.lang.Thread.run(Unknown Source)
18:58:02,359 ERROR [SoapUI] An error occured [com.eviware.soapui.impl.wsdl.support.xsd.SchemaException], see error log for details
com.eviware.soapui.impl.wsdl.support.xsd.SchemaException
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getSchemas(SchemaUtils.java:512)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getSchemas(SchemaUtils.java:327)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.loadSchemaTypes(SchemaUtils.java:192)
at com.eviware.soapui.impl.support.definition.support.XmlSchemaBasedInterfaceDefinition.loadSchemaTypes(XmlSchemaBasedInterfaceDefinition.java:79)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlInterfaceDefinition.load(WsdlInterfaceDefinition.java:61)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:66)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:30)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:268)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.access$400(AbstractDefinitionContext.java:44)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:235)
at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
at java.lang.Thread.run(Unknown Source)
18:58:02,360 ERROR [SoapUI] An error occured [com.eviware.soapui.impl.wsdl.support.xsd.SchemaException], see error log for details
com.eviware.soapui.impl.wsdl.support.xsd.SchemaException
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getSchemas(SchemaUtils.java:512)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getSchemas(SchemaUtils.java:327)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.loadSchemaTypes(SchemaUtils.java:192)
at com.eviware.soapui.impl.support.definition.support.XmlSchemaBasedInterfaceDefinition.loadSchemaTypes(XmlSchemaBasedInterfaceDefinition.java:79)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlInterfaceDefinition.load(WsdlInterfaceDefinition.java:61)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:66)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:30)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:268)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.access$400(AbstractDefinitionContext.java:44)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:235)
at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
at java.lang.Thread.run(Unknown Source)
18:58:02,363 ERROR [AbstractDefinitionContext] Error loading schema types from http://www.webservicemart.com/uszip.asmx?WSDL, see log for details
18:58:35,061 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Connection closed
SOAPUI also provide java API to create request/response
public class SOAPInputGenerator {
public static void main(String[] args) throws Exception {
WsdlProject project = new WsdlProject();
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://localhost:7000/Solicitud?wsdl");
WsdlInterface wsdl = wsdls[0];
for (Operation operation : wsdl.getOperationList()) {
WsdlOperation wsdlOperation = (WsdlOperation) operation;
System.out.println("OP:"+wsdlOperation.getName());
System.out.println("Request:");
System.out.println(wsdlOperation.createRequest(true));
System.out.println("Response:");
System.out.println(wsdlOperation.createResponse(true));
}
}
}
JAR location for SOAP UI libraries
http://www.soapui.org/repository/eviware/jars/
If you don't want use SOAPUI directly , you may find reficio which would be very useful.
Subset of SoapUI library API with example can be find here
https://github.com/reficio/soap-ws
http://www.reficio.org/projects/
This is an open-source project to support SOAP in a purely XML way in Java
You can create the client side stubs using wsimport tool and use jaxb to convert your request object to SOAP xml.
I am trying to solve the below issue for last couple of days but still not able to resolve it. I have searched lots of forums but all in vain.
*Little bit of history: My code was working well in the devp env but for accessing the production sever I received new URL and three new certificates after successfully including the certificates in new trust store file.I am facing below issue. Please help.
2013-11-25 11:32:30,373 INFO[BuilderUtil] OMException in getSOAPBuilder
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]:[1,46]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:198)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:686)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:197)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient$NonBlockingInvocationWorker.run(OutInAxisOperation.java:446)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,46]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
at com.ctc.wstx.sr.BasicStreamReader.startDTD(BasicStreamReader.java:2482)
at com.ctc.wstx.sr.BasicStreamReader.nextFromPrologBang(BasicStreamReader.java:2398)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2058)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:668)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 14 more
2013-11-25 11:32:30,378 INFO [BuilderUtil] Remaining input stream :[]
2013-11-25 11:32:30,380 DEBUG [AuditUtilities] Request Message Id: urn:uuid:5f75a15c-ad57-4d00-b277-75fe7b1e241d
2013-11-25 11:32:30,380 DEBUG [AuditUtilities] Response Message Id: null
2013-11-25 11:32:30,380 DEBUG [AuditUtilities] Response Message Data: null
My SOAP request seems me correct:
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><ns4:product xmlns:ns4="http://ns.electronichealth.net.au/hi/xsd/common/CommonCoreElements/3.0" soapenv:mustUnderstand="false"><ns4:vendor><ns1:qualifier xmlns:ns1="http://ns.electronichealth.net.au/hi/xsd/common/QualifiedIdentifier/3.0">http://ns.electronichealth.net.au/id/hi/vendorid/1.0</ns1:qualifier><ns1:id xmlns:ns1="http://ns.electronichealth.net.au/hi/xsd/common/QualifiedIdentifier/3.0">SDS</ns1:id></ns4:vendor><ns4:productName>HI</ns4:productName><ns4:productVersion>10.1</ns4:productVersion><ns4:platform>LINUX</ns4:platform></ns4:product><h:signature xmlns:h="http://ns.electronichealth.net.au/hi/xsd/common/CommonCoreElements/3.0"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><ds:Reference URI="#body-c3c18409-d0df-4aed-b294-87af248c61f0"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><ds:DigestValue>3pGWeWvyYHDdsDTu0F7qATI3Jp4=</ds:DigestValue></ds:Reference><ds:Reference URI="#timestamp-232e1ed9-f97a-4515-89bd-a3683fab0fce"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><ds:DigestValue>dGJxcKsX+y4jb0ndH1RQDqeWnTw=</ds:DigestValue></ds:Reference><ds:Reference URI="#user-69d4eead-8b69-4e0a-85d7-b2a58867aaa0"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><ds:DigestValue>9ET9aqC4jkINuYY8OhKsAJPEwX8=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>W24rpxUgpbTzxvJUoj5WpBsEssdaaddd56464t4eyYCAa2q9J0izrWIuukvOovde5h+xxxd1+5h/7JREGERGERGEGEGEGRTH5YT34R3EHYJGBDSEFERHJNFGGFFWEBzj7Jj3wfGs3WOLwsvhCuVBRY79mXTAxyQZYiUl7+tk3Pdm5YcSM0ZKfQJyUChIL1mjxALhwdCJkHOneJenjTgFaGRP+0iPF51TDc7l5ruxw8NdsSuN7P8D6lax3Fa4lck2iW/+t43yJ6cqTjZztMPuyKcYUgFhCS4334534234ERFGWBqyZhgRGFREGREG4543645FGER34WEFW4TERSygB8Gj+nx+217qRFTXD8/vcr8/BA1zWDLR05QdyZSDfuOfWTXpgfDcPTqedteeaww5cetv8L5J0dpFvRUkVDFGFGERcTOzmQALQZ+2C81RaNidKeQz++Q==</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>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</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature></h:signature><ns4:timestamp xmlns:ns4="http://ns.electronichealth.net.au/hi/xsd/common/CommonCoreElements/3.0" xml:id="timestamp-232e1ed9-f97a-4515-89bd-a3683fab0fce"><ns4:created>2013-11-25T11:32:27.296+11:00</ns4:created><ns4:expires>2013-11-25T12:32:27.296+11:00</ns4:expires></ns4:timestamp><ns4:user xmlns:ns4="http://ns.electronichealth.net.au/hi/xsd/common/CommonCoreElements/3.0" xml:id="user-69d4eead-8b69-4e0a-85d7-b2a58867aaa0"><ns1:qualifier xmlns:ns1="http://ns.electronichealth.net.au/hi/xsd/common/QualifiedIdentifier/3.0">http://sdspathology.com.au/id/hi/userid/1.0</ns1:qualifier><ns1:id xmlns:ns1="http://ns.electronichealth.net.au/hi/xsd/common/QualifiedIdentifier/3.0">TEST_SDS_USER_ID</ns1:id></ns4:user><wsa:To>https://www3.medicareaustralia.gov.au/pcert/soap/services/</wsa:To><wsa:MessageID>urn:uuid:5f75a15c-ad57-4d00-b277-75fe7b1e241d</wsa:MessageID><wsa:Action>http://ns.electronichealth.net.au/hi/svc/ConsumerSearchIHIBatchAsync/3.0/ConsumerSearchIHIBatchAsyncPortType/submitSearchIHIBatchRequest</wsa:Action></soapenv:Header><soapenv:Body xml:id="body-c3c18409-d0df-4aed-b294-87af248c61f0"><ns12:submitSearchIHIBatch xmlns:ns12="http://ns.electronichealth.net.au/hi/svc/ConsumerSearchIHIBatchAsync/3.0"><ns12:searchIHIBatchRequest><searchIHI xmlns="http://ns.electronichealth.net.au/hi/xsd/consumermessages/SearchIHI/3.0"><s36:medicareCardNumber xmlns:s36="http://ns.electronichealth.net.au/hi/xsd/consumercore/ConsumerCoreElements/3.0">2950249651</s36:medicareCardNumber></searchIHI><ns11:requestIdentifier xmlns:ns11="http://ns.electronichealth.net.au/hi/xsd/consumermessages/SearchIHIBatch/3.0">d1f21610-6cb9-4e60-9673-18f43a4500b5</ns11:requestIdentifier></ns12:searchIHIBatchRequest></ns12:submitSearchIHIBatch></soapenv:Body></soapenv:Envelope>
Please suggest.
Had a very similar issue. The WSDL file is delivered, but calls on the bind address fail with this bogus doctype error. In our prod environment, http requests coming from outside the corporate network are swapped across to https. The solution was to request the WSDL file using https, then everything worked.
The problem is that the response is not XML, it is most likely a HTML page. In my case, the SOAP service I was requesting did not exist so I was getting a HTML error page, which starts like
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
There error is referring to that second-last character, the double quote.
I had a similar problem.
You should have a syntax error at line 46 in your wsdl file
[row,col {unknown-source}]:[1,46]
I had the same problem.
I always receive this error when the response of my request is an unexpected HTML. I usually receive this response when I call to a request (URI) that the server doesn`t know and go back a 404 error code.
I had the same error message, but that is also for XML attributes as..:
<add>
<doc>
<field name=id>48</field> <!-- Incorrect -->
<field name="id">48</field><!-- Correct -->
.....
</doc>
</add>
I had an ampersand symbol (&) in a table, and then I used Jira's Page Properties Report macro to show that content from that cell, and it was failing with a similar error.
I am using Metro 2 client to consume the "Secure wcf web service in Java". But Metro client does not gives any response and stay in hang mode after very long time it produce the output as an error:
Stack Trace:
SEVERE: WSSMSG0001: Error occurred while buffering incoming SOAP message.
com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x1a
at [row,col {unknown-source}]: [1,6396222]
at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479)
at com.ctc.wstx.sr.StreamScanner.reportIllegalChar(StreamScanner.java:2442)
at com.ctc.wstx.sr.StreamScanner.validateChar(StreamScanner.java:2389)
at com.ctc.wstx.sr.StreamScanner.resolveCharEnt(StreamScanner.java:2355)
at com.ctc.wstx.sr.StreamScanner.fullyResolveEntity(StreamScanner.java:1501)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2726)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1065)
at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.bridge(XMLStreamReaderToXMLStreamWriter.java:142)
at com.sun.xml.ws.message.stream.StreamMessage.writePayloadTo(StreamMessage.java:376)
at com.sun.xml.ws.message.stream.StreamMessage.writeEnvelope(StreamMessage.java:412)
at com.sun.xml.ws.message.stream.StreamMessage.writeTo(StreamMessage.java:390)
at com.sun.xml.ws.security.message.stream.LazyStreamBasedMessage.readMessage(LazyStreamBasedMessage.java:476)
at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.verifyInboundMessage(SecurityTubeBase.java:444)
at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processClientResponsePacket(SecurityClientTube.java:434)
at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processResponse(SecurityClientTube.java:362)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:972)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:910)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:873)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:775)
at com.sun.xml.ws.client.Stub.process(Stub.java:429)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:168)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
at $Proxy44.pullCustomers(Unknown Source)
at com.tekriti.client.Client.test(Client.java:106)
at com.tekriti.client.Client.main(Client.java:44)
com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.stream.XMLStreamException: Internal XSB error: Invalid State=0]
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:141)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
at $Proxy44.pullCustomers(Unknown Source)
at com.tekriti.client.Client.test(Client.java:106)
at com.tekriti.client.Client.main(Client.java:44)
Caused by: javax.xml.bind.UnmarshalException
I am trying to fix this issue but no luck, Metro client is unable to parse the SOAP response in a correct way. I don't know where I am doing mistake or I have to use something else.
I am using Netbeans 7.1 and Metro 2.2.
Please give your suggestions or if you had such problem in your past please do share with me.
updated:
This is working fine:
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);
((BindingProvider)sourceDispatch).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://cdx.dealerbuilt.com/Api/0.97/IStandardApi/PullCustomers");
((BindingProvider)sourceDispatch).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
req contains the below one:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action>http://cdx.dealerbuilt.com/Api/0.97/IStandardApi/PullCustomers</Action>
</s:Header>
<s:Body>
<PullCustomers xmlns="http://cdx.dealerbuilt.com/Api/0.97/">
<searchCriteria xmlns:d4p1="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:ActivityStoreIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:long>64</d5p1:long>
</d4p1:ActivityStoreIds>
<d4p1:EnvironmentIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:long>27</d5p1:long>
</d4p1:EnvironmentIds>
</searchCriteria>
</PullCustomers>
</s:Body>
</s:Envelope>
But it produces Source in output and takes SOAP envelope in request.
I Need this should be work.
org.tempuri.StandardApi service = new org.tempuri.StandardApi();
CustomerSearchCriteriaType criteriaType = new CustomerSearchCriteriaType();
QName environmentQName = new QName("http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi", "EnvironmentIds");
ArrayOflong arrayOflong = new ArrayOflong();
arrayOflong.getLong().add(27l);
JAXBElement<ArrayOflong> environmentIds = new JAXBElement<ArrayOflong>(environmentQName, ArrayOflong.class, arrayOflong);
criteriaType.setEnvironmentIds(environmentIds);
QName activityQName = new QName("http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi", "ActivityStoreIds");
ArrayOflong arrayOfActivity = new ArrayOflong();
arrayOfActivity.getLong().add(64l);
JAXBElement<ArrayOflong> activityIds = new JAXBElement<ArrayOflong>(activityQName, ArrayOflong.class, arrayOfActivity);
criteriaType.setActivityStoreIds(activityIds);
ArrayOfCustomerType customers = service.getCustomBindingIStandardApi().pullCustomers(criteriaType);
if (customers != null) {
System.out.println("Size of Customers::::" + customers.getCustomer().size());
}
Request contains
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<PullCustomers xmlns="http://cdx.dealerbuilt.com/Api/0.97/">
<searchCriteria>
<ActivityStoreIds xmlns="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi">
<long xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">64</long>
</ActivityStoreIds>
<EnvironmentIds xmlns="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi">
<long xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">27</long>
</EnvironmentIds>
</searchCriteria>
</PullCustomers>
</soapenv:Body>
</soapenv:Envelope>
But it hangs while producing output and after very long time it produce the error mentioned above.
Is the difference between the requests causes the problem or something else?
I think the data web-service is returning to client contain illegal character 0x1a which is EOF.
XML doesn't allow CONTROL CHAR in it. As you are using SOAP ultimately XML.
See the similar issue: illegal character in xml document
solution:
1. Either you can eliminate CONTROL char
2. Or Encode it in web-service and decode it at SOAP client.
I have implement a certain spring-ws service and when I sent a soap message I receive in spring webapplication 1 (running on tomcat 6.0.32):
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gen="http://www.foo.com/bar/webservice/generated">
<soapenv:Header/>
<soapenv:Body>
<gen:GetAllPanelWSRequest/>
</soapenv:Body>
</soapenv:Envelope>
Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:GetAllPanelWSResponse xmlns:ns2="http://www.foo.com/bar/webservice/generated">
<ns2:PanelWS ns2:Id="5">
<ns2:name>all</ns2:name>
<ns2:code>all</ns2:code>
</ns2:PanelWS>
<ns2:PanelWS ns2:Id="9">
<ns2:name>test</ns2:name>
<ns2:code>test1</ns2:code>
</ns2:PanelWS>
</ns2:GetAllPanelWSResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So far no problem. From a webappliction 2 (not using spring MVC etc.) I made a function and when I run this function it works:
Main.java:
...
public class Main {
public static void main(String[] args) {
List<PanelWS> panelWSs = CallServices.getPanelWSs();
for (PanelWS p : panelWSs) {
System.out.println("\t" + makeString(p));
}
}
...
CallServices.java
public static List<PanelWS> getPanelWSs() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
PanelClient client = (PanelClient) ctx.getBean("client");
PanelWS panelWS = null;
// Get all panelWS
System.out.println("Get all panels...");
List<PanelWS> panelWSs = client.getAllPanelWS();
return panelWSs;
}
Output:
Get all panels...
[id=5, name=all, code=all]
[id=9, name=test, code=test1]
So this works great and as expected. But when I want to call the function
<%
List<PanelWS> panelWSs = CallServices.getPanelWSs();
%>
within a JSP (runnning on the same tomcat server) or a simple class I get the following error:
Server:
13-mei-2011 17:57:37 com.sun.xml.internal.messaging.saaj.soap.MessageImpl saveChanges
SEVERE: SAAJ0539: Unable to get header stream in saveChanges
13-mei-2011 17:57:37 com.sun.xml.internal.messaging.saaj.soap.MessageImpl saveChanges
SEVERE: SAAJ0540: Error during saving a multipart message
Client:
org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not write message to OutputStream: Error during saving a multipart message; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
I'm using the following Java version pointing to myeclipse and tomcat (runs on):
*JDK 1.6.0_13*
Jars:
xercesImpl-2.9.1.jar
xalan-2.7.1.jar
serializer-2.7.1.jar
spring-ws-1.5.9-all.jar
spring.jar(2.5.6)
xml-apis-1.3.04.jar
xml-apis-ext-1.3.04.jar
Full stacktrace of client
Message: org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not write message to OutputStream: Error during saving a multipart message; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
Error ID: #9yb3mzb7
Stack trace: org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:169)
org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:580)
org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:549)
org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:502)
org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:351)
org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:345)
org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:337)
com.foo.bar.webservice.client.PanelMGMClientImpl.getAllPanelWS(PanelMGMClientImpl.java:22)
com.foo.bar.webservice.client.CallServices.getPanelWSs(CallServices.java:22)
org.apache.jsp.workspace.aclusers_jsp._jspService(aclusers_jsp.java:786)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
Fullstacktrace of server
**
**SEVERE: Servlet.service() for servlet spring-ws threw exception
java.io.IOException: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:298)
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:309)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:305)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getHeaderBytes(MessageImpl.java:947)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1098)
at org.springframework.ws.soap.saaj.Saaj13Implementation.writeTo(Saaj13Implementation.java:268)
at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:165)
at org.springframework.ws.transport.AbstractWebServiceConnection.send(AbstractWebServiceConnection.java:45)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:97)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.foo.bar.support.gzip.CompressionFilter.doFilter(CompressionFilter.java:30)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:168)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
at java.lang.Thread.run(Thread.java:619)
16-mei-2011 14:20:12 com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory createEnvelope
SEVERE: SAAJ0511: Unable to create envelope from given source**
**
hopefully this is enough information to solve the problem. I found some messages and bugs the pointing to the fact that I need to delete some Jars (xalan,xercesImpl and serializer) from the projects and add these jars to the jdk\lib\endorsed\ folder and add to tomcat the argument: -Djava.endorsed.dirs=. This works but I can't do this because the applications is running on several servers already.
Thx in advance
Alternative solution
Solved It for now while using the Apache CXF on the client. And spring-ws 1.5.9 on the server... apparently spring-ws sucks with jdk > 1.5
Maybe you should try considering updating to xerces-2.10.x, the problem can be that in jdk6 (rt.jar) there is a com.sun.org.apache.xerces package which seem to contain a jaxp 1.4 implementation, so does xerces 2.10+:
"It also contains an implementation of
the parser related portions of JAXP
1.4"
quote from here.
Are you building the binary containing the jsp as a separate process or you are building everything together? If it's separated, you can try to remove xerces and xalan from the buildpath of that package only? - If you cannot, try upgrading maybe it'll help.
Still think it would be better to have a service calling your ws and you'd invoke that service from the jsp, that way you could test it separately, but perhaps you can't do that for some reason.
If both of these fail, can you post a) full stacktrace b) some of the errors which appear if you remove xerces and xalan alltogether?
Solved It for now using the Apache CXF 2.4.0 on the client. And spring-ws 1.5.9 on the server... apparently spring-ws sucks with jdk > 1.5
This is a known issue with Spring-WS and Java 6, see ticket SWS-175. According to this ticket the solution is to remove Xalan and Xerces from your webapp classpath.