Hi Eugene,
I was trying to make a client server wsdl 1.1 with soap1.2 application
with Scalaxb and Dispatch, but I got an Envelope version mismatch.
SEVERE: Couldn't create SOAP message. Expecting Envelope in namespace
http://sch
emas.xmlsoap.org/soap/envelope/, but got
http://www.w3.org/2003/05/soap-envelope
com.sun.xml.internal.ws.protocol.soap.VersionMismatchException:
Couldn't create
SOAP message. Expecting Envelope in namespace
http://schemas.xmlsoap.org/soap/en
velope/, but got
http://www.w3.org/2003/05/soap-envelope
I am searching all day, but I don't know why it is expecting namespace
http://schemas.xmlsoap.org/soap/en
velope/ (wsdl, annotations, dependencies?)
Something else, maybe this issue is already fix in the trunk:
I have embedded the schema because when I import it using xs:import,
it generates wstest.scala twice and thus overwriting each other.
The trait WSTest with the webmethod test is missing then, but case
class Test and TestResponse and the other case classes are there.
Greetings,
Dave
Scala 2.9.1.RC4
JDK7 b147
Windows 7 Home Premium 32 bit + SP1
scalaxb 0.6.2
wstest.wsdl
===========
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:tns="org.scalaxbtest/WS"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/"
xmlns:wsoap12="
http://schemas.xmlsoap.org/wsdl/
soap12/"
targetNamespace="org.scalaxbtest/WS"
name="WSTest">
<wsdl:types>
<xs:schema version="1.0"
elementFormDefault="qualified"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:tns="org.scalaxbtest/WS"
xmlns:ws="org.scalaxbtest/WS"
targetNamespace="org.scalaxbtest/WS">
<xs:complexType name="Child">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:int"/>
<xs:element name="birthdate" type="xs:date"
minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Person">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="ws:Address"/>
<xs:element name="children">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="ws:Child"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="test" type="tns:test"></xs:element>
<xs:element name="testResponse" type="tns:testResponse"></
xs:element>
<xs:complexType name="test">
<xs:sequence>
<xs:element name="person" type="ws:Person"
minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testResponse">
<xs:sequence>
<xs:element name="return" type="xs:string"
minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="test">
<wsdl:part name="parameters" element="tns:test"></wsdl:part>
</wsdl:message>
<wsdl:message name="testResponse">
<wsdl:part name="parameters" element="tns:testResponse"></
wsdl:part>
</wsdl:message>
<wsdl:portType name="WSTest">
<wsdl:operation name="test">
<wsdl:input wsam:Action="org.scalaxbtest/WS/
org.scalaxbtest/WS/testRequest" message="tns:test"></wsdl:input>
<wsdl:output wsam:Action="org.scalaxbtest/WS/
org.scalaxbtest/WS/testResponse" message="tns:testResponse"></
wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WSTest" type="tns:WSTest">
<wsoap12:binding transport="
http://schemas.xmlsoap.org/soap/
http" style="document"></wsoap12:binding>
<wsdl:operation name="test">
<wsoap12:operation soapAction=""></wsoap12:operation>
<wsdl:input>
<wsoap12:body use="literal"></wsoap12:body>
</wsdl:input>
<wsdl:output>
<wsoap12:body use="literal"></wsoap12:body>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WSTest">
<wsdl:port name="WSTest" binding="tns:WSTest">
<wsoap12:address location="
http://localhost:8080/wstest"></
wsoap12:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
webserviceserver.scala
======================
package webserviceserver
import scalaxb._
import ws._
import javax.xml.ws.Endpoint
import javax.jws.WebParam
import javax.jws.WebService
@WebService(targetNamespace="org.scalaxbtest/WS",
name="org.scalaxbtest/WS", portName="test", serviceName="WSTest")
private class MinimalSoapServer extends WSTest{
def test(@WebParam(name = "person") person : Option[Person]) =
{ person match {
case Some(p) =>
{ println(p); Right(Some("Hi " +
p.name)) }
case _ => Left(new
Fault("error", person))}
}
}
object MinimalSoapServer extends App {
val endpoint = Endpoint.publish("
http://localhost:8080/wstest",
new MinimalSoapServer())
System.out.println("Waiting for requests...")
}
Used Dispatch dependencies in CLASSPATH
=======================================
commons-logging-1.1.1.jar
dispatch-core_2.9.0-1-0.8.3.jar
dispatch-futures_2.9.0-1-0.8.3.jar
dispatch-http_2.9.0-1-0.8.3.jar
dispatch-lift-json_2.9.0-1-0.8.3.jar
httpclient-4.1.jar
httpcore-4.1.jar
C:\scala-2.9.1.RC4\examples\scalaxb\webservicesoap\app>scala -cp .;..
webservice
server.MinimalSoapServer
Waiting for requests...
aug 31, 2011 5:34:14 PM
com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpT
oolkit handle
SEVERE: Couldn't create SOAP message. Expecting Envelope in namespace
http://sch
emas.xmlsoap.org/soap/envelope/, but got
http://www.w3.org/2003/05/soap-envelope
com.sun.xml.internal.ws.protocol.soap.VersionMismatchException:
Couldn't create
SOAP message. Expecting Envelope in namespace
http://schemas.xmlsoap.org/soap/en
velope/, but got
http://www.w3.org/2003/05/soap-envelope
at
com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCod
ec.java:167)
at
com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCod
ec.java:292)
at
com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCod
ec.java:118)
at
com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingC
odec.java:343)
at
com.sun.xml.internal.ws.transport.http.HttpAdapter.decodePacket(HttpA
dapter.java:321)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.access
$400(HttpAda
pter.java:81)
at com.sun.xml.internal.ws.transport.http.HttpAdapter
$HttpToolkit.handle
(HttpAdapter.java:576)
at
com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter
.java:244)
at
com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExc
hange(WSHttpHandler.java:95)
at
com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WS
HttpHandler.java:80)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:
77)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:
80)
at sun.net.httpserver.ServerImpl$Exchange
$LinkHandler.handle(ServerImpl.
java:665)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:
77)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:
637)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1110)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor
.java:603)
at java.lang.Thread.run(Thread.java:722)
Copy and pastable lines
=======================
import scalaxb._
import ws._
val service = (new WSTestBindings with SoapClients with
DispatchHttpClients {}).service
val xgc =
javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar("2004-09-04T18:06:22Z")
val caseclassperson =
Person("joe",Address("Bulevard","Helsinki"),Children(Child("Mary",
5,Some(xgc)),Child("Mazy",3, None)))
println(service.test(Some(caseclassperson)))
REPL session (MinimalSoapServer is running in other console)
============================================================
C:\scala-2.9.1.RC4\examples\scalaxb\webservicesoap>scala
Welcome to Scala version 2.9.1.RC4 (Java HotSpot(TM) Client VM, Java
1.7.0).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scalaxb._
import scalaxb._
scala> import ws._
import ws._
scala> val service = (new WSTestBindings with SoapClients with
DispatchHttpClien
ts {}).service
service: ws.WSTest = ws.XMLProtocol$WSTestBindings$$anon$7@106f265
scala> val xgc =
javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregori
anCalendar("2004-09-04T18:06:22Z")
xgc: javax.xml.datatype.XMLGregorianCalendar = 2004-09-04T18:06:22Z
scala> val caseclassperson =
Person("joe",Address("Bulevard","Helsinki"),Childre
n(Child("Mary",5,Some(xgc)),Child("Mazy",3, None)))
caseclassperson: ws.Person =
Person(joe,Address(Bulevard,Helsinki),Children(Wrap
pedArray(Child(Mary,5,Some(2004-09-04T18:06:22Z)), Child(Mazy,
3,None))))
scala> println(service.test(Some(caseclassperson)))
INF: [console logger] dispatch: localhost POST /wstest HTTP/1.1
dispatch.StatusCode: Unexpected response code: 500
<?xml version="1.0" ?><S:Envelope xmlns:S="
http://schemas.xmlsoap.org/
soap/envel
ope/"><S:Body><S:Fault xmlns:ns3="
http://www.w3.org/2003/05/soap-
envelope"><faul
tcode>S:VersionMismatch</faultcode><faultstring>Couldn't create SOAP
message. Ex
pecting Envelope in namespace
http://schemas.xmlsoap.org/soap/envelope/,
but got
http://www.w3.org/2003/05/soap-envelope</faultstring></S:Fault></S:Body></S:Env
elope>
at dispatch.HttpExecutor$$anonfun$when$1.apply(executor.scala:
53)
at dispatch.HttpExecutor$$anonfun$when$1.apply(executor.scala:
50)
at dispatch.HttpExecutor$$anonfun$x$2.apply(executor.scala:41)
at dispatch.HttpExecutor$$anonfun$x$2.apply(executor.scala:36)
at dispatch.BlockingHttp$$anonfun$execute$1.apply(Http.scala:
54)
at dispatch.Http.pack(Http.scala:25)
at dispatch.BlockingHttp$class.execute(Http.scala:53)
at dispatch.Http.execute(Http.scala:21)
at dispatch.HttpExecutor$class.x(executor.scala:36)
at dispatch.Http.x(Http.scala:21)
at dispatch.HttpExecutor$class.when(executor.scala:50)
at dispatch.Http.when(Http.scala:21)
at dispatch.HttpExecutor$class.apply(executor.scala:60)
at dispatch.Http.apply(Http.scala:21)
at scalaxb.DispatchHttpClients$DispatchHttpClient
$class.request(httpclie
nts_dispatch.scala:12)
at scalaxb.DispatchHttpClients$$anon
$1.request(httpclients_dispatch.scal
a:4)
at scalaxb.SoapClients$SoapClient$class.soapRequest(soap.scala:
38)
at scalaxb.SoapClients$$anon$1.soapRequest(soap.scala:24)
at scalaxb.SoapClients$SoapClient
$class.requestResponse(soap.scala:47)
at scalaxb.SoapClients$$anon$1.requestResponse(soap.scala:24)
at ws.XMLProtocol$WSTestBindings$WSTestBinding
$class.test(wstest_xmlprot
ocol.scala:130)
at ws.XMLProtocol$WSTestBindings$$anon
$7.test(wstest_xmlprotocol.scala:1
25)
at .<init>(<console>:17)
at .<clinit>(<console>)
at .<init>(<console>:11)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala.tools.nsc.interpreter.IMain
$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun
$14.apply(IMain.sca
la:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV
$sp(Line.scala:4
3)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:722)