- This topic has 1 reply, 1 voice, and was last updated 18 years, 5 months ago by toconnor.
-
AuthorPosts
-
toconnorMemberI have generated a “top down” web service using JAXB2 binding. (I also tried this using XMLBeans binding which didn’t work. See http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-13232.html.) The wsdl is for an existing web service we recently implemented with Apache Axis. The web service appears to generate correctly. I get java classes (2) for each of the complex data types specified by the wsdl. The annotations that specify element order (@XmlType) and mapping of java variables to element names (@XmlElement) appear to be correct. I modified the “impl” class to return a valid response. I am able to deploy the web service project (WebLogic 9.1). The problems occur when I try to use it.
The first thing you notice is that the generated wsdl (endpoint?wsdl) mismatches the contract wsdl used to generate the service in critical ways. The elements of the complex data types are in a different order. In some cases element names are different (different casing etc.). It appears that the generated wsdl represents a serialization of the java classes, but without reference to the annotations that specify proper order or mapping of java variable names to xml element names. When you try and test by referencing endpoint?wsdl, it fails. The exact message is:
<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Parameter { http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23 }getHomeScorein0 does not exist!</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>(I used XMLSpy for testing in the above example.) Trying to use the original contract wsdl to access the web service also fails.
Using the generated test client to access the service (via a jsp) throws the following exception:
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Parameter {http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23}HomePolicy does not exist!
at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:92)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy20.getHomeScore(Unknown Source)
at jsp_servlet.__myjsp._jspService(__myjsp.java:127)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:380)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:298)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3153)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
Caused by: org.codehaus.xfire.fault.XFireFault: Parameter {http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23}HomePolicy does not exist!
at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:110)
at org.codehaus.xfire.client.Client.onReceive(Client.java:382)
at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
at org.codehaus.xfire.transport.local.LocalChannel$2.run(LocalChannel.java:176)
at java.lang.Thread.run(Thread.java:595)I have tried to modify the generated services.xml to include a reference to <serviceFactory>org.codehaus.xfire.jaxb2.JaxbServiceFactory</serviceFactory>, but this just caused other problem, probably because I don’t know what I am doing.
Based on BEA and Xfire references, modified server paths (WebLogic 9.1) as follows, but this didn’t help:
– Added JVM argument -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0
– Prepended xfire-jsr181-api-1.0-M1.jar to classpath
We have tried this with other wsdl’s with the same reesult (All had complex data types.) Thanks fo any help on this. Below find the following. wsdl used to generate JAXB service. generated wsdl (endpoint?wsdl), service.xml, my configuation.
WSDL used to generate sevice
<?xml version=”1.0″ encoding=”UTF-8″?>
<wsdl:definitions targetNamespace=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″ xmlns:apachesoap=”http://xml.apache.org/xml-soap” xmlns:impl=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″ xmlns:intf=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″ xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/” xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<!–WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)–>
<wsdl:types>
<schema elementFormDefault=”qualified” targetNamespace=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″ xmlns=”http://www.w3.org/2001/XMLSchema”>
<complexType name=”HomePolicyType”>
<sequence>
<element name=”PolicyNbr” nillable=”true” type=”xsd:string”/>
<element name=”NewRewnewInd” nillable=”true” type=”xsd:string”/>
<element name=”CompanyCde” nillable=”true” type=”xsd:string”/>
<element name=”LOBCde” type=”xsd:string”/>
<element name=”WrittenDte” nillable=”true” type=”xsd:string”/>
<element name=”EffDte” nillable=”true” type=”xsd:string”/>
<element name=”StateCde” nillable=”true” type=”xsd:string”/>
<element name=”HouseholdRiskScoreNbr” nillable=”true” type=”xsd:string”/>
<element name=”TenureYearsNbr” nillable=”true” type=”xsd:string”/>
<element name=”Claims0_1Nbr” nillable=”true” type=”xsd:string”/>
<element name=”Claims1_2Nbr” nillable=”true” type=”xsd:string”/>
<element name=”Claims2_3Nbr” nillable=”true” type=”xsd:string”/>
</sequence>
</complexType>
<element name=”HomePolicy” type=”impl:HomePolicyType”/>
<complexType name=”HomePolicyScoreType”>
<sequence>
<element name=”TotalPointsNbr” nillable=”true” type=”xsd:string”/>
<element name=”HouseHoldRiskPointsNbr” nillable=”true” type=”xsd:string”/>
<element name=”TenurePointsNbr” nillable=”true” type=”xsd:string”/>
<element name=”ClaimPointsNbr” nillable=”true” type=”xsd:string”/>
<element name=”RatingDiscountPct” nillable=”true” type=”xsd:string”/>
<element name=”DiscountFactorPct” nillable=”true” type=”xsd:string”/>
<element name=”ErrorCde” nillable=”true” type=”xsd:string”/>
<element name=”ErrorDsc” nillable=”true” type=”xsd:string”/>
</sequence>
</complexType>
<element name=”HomePolicyScore” type=”impl:HomePolicyScoreType”/>
</schema>
</wsdl:types><wsdl:message name=”GetHomeScoreResponse”>
<wsdl:part element=”impl:HomePolicyScore” name=”HomePolicyScore”/>
</wsdl:message>
<wsdl:message name=”GetHomeScoreRequest”>
<wsdl:part element=”impl:HomePolicy” name=”HomePolicy”/>
</wsdl:message>
<wsdl:portType name=”ScorecardInterface”>
<wsdl:operation name=”GetHomeScore” parameterOrder=”HomePolicy”>
<wsdl:input message=”impl:GetHomeScoreRequest” name=”GetHomeScoreRequest”/>
<wsdl:output message=”impl:GetHomeScoreResponse” name=”GetHomeScoreResponse”/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=”ScorecardSoapBinding” type=”impl:ScorecardInterface”>
<wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/>
<wsdl:operation name=”GetHomeScore”>
<wsdlsoap:operation soapAction=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23:getHomeScoreIn”/>
<wsdl:input name=”GetHomeScoreRequest”>
<wsdlsoap:body use=”literal”/>
</wsdl:input>
<wsdl:output name=”GetHomeScoreResponse”>
<wsdlsoap:body use=”literal”/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=”Scorecard”>
<wsdl:port binding=”impl:ScorecardSoapBinding” name=”Scorecard”>
<wsdlsoap:address location=”http://localhost:7001/ServiceTest02/services/Scorecard”/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Generated wsdl (endpoint?wsdl) Note different element order, naming etc.
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<wsdl:definitions xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/” xmlns:ns1=”http://_23._05._2006.scorecard.services.pricing.xmlschemas.sentry.com” xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope” xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding” xmlns:tns=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″ xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” targetNamespace=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″>
<wsdl:types xmlns:tns=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″>
<xsd:schema targetNamespace=”http://_23._05._2006.scorecard.services.pricing.xmlschemas.sentry.com” elementFormDefault=”qualified” attributeFormDefault=”qualified”>
<xsd:complexType name=”HomePolicyType”>
<xsd:sequence>
<xsd:element name=”LOBCde” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”claims01Nbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”claims12Nbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”claims23Nbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”companyCde” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”effDte” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”householdRiskScoreNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”newRewnewInd” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”policyNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”stateCde” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”tenureYearsNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”writtenDte” type=”xsd:string” minOccurs=”0″ nillable=”true” />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=”HomePolicyScoreType”>
<xsd:sequence>
<xsd:element name=”claimPointsNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”discountFactorPct” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”errorCde” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”errorDsc” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”houseHoldRiskPointsNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”ratingDiscountPct” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”tenurePointsNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
<xsd:element name=”totalPointsNbr” type=”xsd:string” minOccurs=”0″ nillable=”true” />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema targetNamespace=”http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23″ elementFormDefault=”qualified” attributeFormDefault=”qualified”>
<xsd:element name=”getHomeScorein0″ type=”ns1:HomePolicyType” />
<xsd:element name=”getHomeScoreout” type=”ns1:HomePolicyScoreType” />
</xsd:schema>
</wsdl:types>
<wsdl:message name=”getHomeScoreRequest”>
<wsdl:part element=”tns:getHomeScorein0″ name=”getHomeScorein0″ />
</wsdl:message>
<wsdl:message name=”getHomeScoreResponse”>
<wsdl:part element=”tns:getHomeScoreout” name=”getHomeScoreout” />
</wsdl:message>
<wsdl:portType name=”ScorecardPortType”>
<wsdl:operation name=”getHomeScore”>
<wsdl:input message=”tns:getHomeScoreRequest” name=”getHomeScoreRequest” />
<wsdl:output message=”tns:getHomeScoreResponse” name=”getHomeScoreResponse” />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=”ScorecardHttpBinding” type=”tns:ScorecardPortType”>
<wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http” />
<wsdl:operation name=”getHomeScore”>
<wsdlsoap:operation soapAction=”” />
<wsdl:input name=”getHomeScoreRequest”>
<wsdlsoap:body use=”literal” />
</wsdl:input>
<wsdl:output name=”getHomeScoreResponse”>
<wsdlsoap:body use=”literal” />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=”Scorecard”>
<wsdl:port binding=”tns:ScorecardHttpBinding” name=”ScorecardHttpPort”>
<wsdlsoap:address location=”http://localhost:7001/ServiceTest02/services/Scorecard” />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>Service xml
<beans xmlns=”http://xfire.codehaus.org/config/1.0″>
<service>
<name>Scorecard</name>
<namespace>
http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23
</namespace>
<serviceClass>
com.jwb.scorecard.ScorecardInterface
</serviceClass>
<implementationClass>
com.jwb.scorecard.ScorecardImpl
</implementationClass>
<style>document</style>
<use>literal</use>
<scope>application</scope>
</service></beans>Configuration
*** Date: Tue Jul 11 15:23:31 CDT 2006
*** System properties:
OS=Windows2000
OS version=5.0
Java version=1.5.0_04*** MyEclipse details:
MyEclipse Enterprise WorkbenchVersion: 5.0 Milestone 2
Build id: 20060703-5.0-M2*** Eclipse details:
Eclipse SDKVersion: 3.2.0
Build id: M20060629-1905Eclipse Graphical Editing Framework
Version: 3.2.0.v20060626
Build id: 20060627-0816Eclipse Platform
Version: 3.2.0.v20060609m-AgOexn6hlEUsvBO
Build id: M20060629-1905Eclipse RCP
Version: 3.2.0.v20060609m-SVDNgVrNoh-MeGG
Build id: M20060629-1905Eclipse Java Development Tools
Version: 3.2.0.v20060609m-F7snq1fxia-Z4XP
Build id: M20060629-1905Eclipse Plug-in Development Environment
Version: 3.2.0.v20060609m——6zXJJzJzJq
Build id: M20060629-1905Eclipse Project SDK
Version: 3.2.0.v20060609m-GNq6oQq-7es-Y81
Build id: M20060629-1905Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\eclipse32\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
834_7c
-vm
C:\bea\jdk150_04\jre\bin\javaw.exe
toconnorMemberI did finally get this to work, but there are still some issues including the fact that I can only access the service wsdl once. Here is what I had to do.
Change Bea 9.1 server preferences as follows:
– Added JVM argument -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0
– Prepended xfire-jsr181-api-1.0-M1.jar to classpath
Modified services xml as follows. See embedded comments. Note change to <serviceClass> and addition of <serviceFactory>
<beans xmlns=”http://xfire.codehaus.org/config/1.0″>
<service>
<name>Scorecard</name>
<namespace>
http://xmlschemas.sentry.com/Pricing/Services/Scorecard/2006/05/23
</namespace>
<!– ServiceClass MUST reference actual implementation,
not just the interface –>
<serviceClass>
com.jwb.scorecard.ScorecardImpl
</serviceClass>
<!– (remove)
<implementationClass>
com.jwb.scorecard.ScorecardImpl
</implementationClass>
–>
<!– Add service factrory –>
<serviceFactory>
org.codehaus.xfire.jaxb2.JaxbServiceFactory
</serviceFactory>
<style>document</style>
<use>literal</use>
<scope>application</scope>
</service></beans>endpoint?wsdl now returns a valid wsdl. I can use xmlspy, for example, to access my web service. There are still some issues:
– The wsdl being returned does not appear to be generated by the service. Rather it is the wsdl on the file system that was used to generate the service and is specified by the wsdlLocation attribute of the @WebService annotation. So, for example, I had to go in and change the endpoint on the wsdl file to match my actual service endpoint. For other systems that I have worked with (AXIS, VB.Net), the web service engine actually generates the wsdl internally including an endpoint for the context in which the service is running. I’m not sure how this is going to work in the real world (migrations from test –> prod, what if the wsdl was specified by url, what if the wsdl imports xsd’s etc.)
– There is still a bug in that I can only use the wsdl once. If I try endpoint?wsdl a second time, it hangs and the following exception is thrown:org.codehaus.xfire.XFireRuntimeException: Couldn’t generate WSDL.. Nested exception is java.io.IOException: Stream closed
at org.codehaus.xfire.DefaultXFire.generateWSDL(DefaultXFire.java:108)
at org.codehaus.xfire.transport.http.XFireServletController.generateWSDL(XFireServletController.java:317)
at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:116)
at org.codehaus.xfire.transport.http.XFireServlet.doGet(XFireServlet.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
Truncated. see log file for complete stacktrace
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:145)
at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at org.codehaus.xfire.wsdl.ResourceWSDL.copy(ResourceWSDL.java:60)
at org.codehaus.xfire.wsdl.ResourceWSDL.write(ResourceWSDL.java:47)
Truncated. see log file for complete stacktrace
I have to stop and start the server.On another note, I also tried this using <serviceFactory>jsr181</serviceFactory>
I was able to use xmlspy to pull the wsdl and send a request to the server. However, elements within my complex type came back in the wrong order. In fact they appeared to come back in alphabetical order!!What service factory should I use, or should I have to specify one at all?
Is Xfire supposed to generate a wsdl, or just pull the wsdl file specified in the annotations?Thanks……..
-
AuthorPosts