2012-03-07 53 views
1

我已經使用CXF部署了合同優先的Web服務。通過SSL重定向使用<wsdl:import>消費web服務

將其部署到的服務器執行302從http到ssl的重定向,因此任何到http://server/app/ *的請求都會返回HTTP 302錯誤代碼並重定向到https://server/app/ *。

在原始WSDL中有對另一個命名空間中的XSD元素的引用,所以生成的WSDL(提供的那個)包含一個<wsdl:import>元素。

如果我嘗試通過手動構建一個字符串中的SOAP請求並通過SSL套接字發送它來調用WS,那麼WS響應正確。我已在我的密鑰庫中獲得所有必需的證書。

但是,當我嘗試建立利用CXF的WSDL2Java的指向客戶端https://server/app/services/MyService?wsdl,我得到以下錯誤(以下完整堆棧跟蹤):

[Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: 
    White spaces are required between publicId and systemId. 

跟蹤是指<wsdl:import>聲明。它的location屬性是http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl。我的猜測是錯誤是由於302重定向引發的。它應該是https://server/app/services/MyService?wsdl=MyServicePortType.wsdl

原始WSDL與URL無關,並且該服務的URL在Spring元素中相對定義。它通過CXF servlet訪問。也就是說,原始WSDL的<wsdl:port>中沒有<soap:address>元素。

<import resource="classpath:META-INF/cxf/cxf.xml"/> 
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 
<bean id="myServiceBean" class="mypackage.MyServiceImpl" /> 
<jaxws:endpoint 
    id="myServiceEndpoint" 
    implementor="#myServiceBean" 
    address="/MyService"> 
</jaxws:endpoint> 

我應該某處指定服務的自動生成的類,WSDL或Spring配置,該服務將被部署在SSL?我怎麼能這樣做?

編輯: 可能相關鏈接:上markmail

完整的堆棧跟蹤:

D:\>wsdl2java -d src -client -impl -verbose -db xmlbeans -autoNameResolution -validate -compile -classdir classes https://server/app/services/MyService?wsdl 
Loading FrontEnd jaxws ... 
Loading DataBinding xmlbeans ... 
wsdl2java -d src -client -impl -verbose -db xmlbeans -autoNameResolution -valida 
te -compile -classdir classes https://server/app/services/MyService?wsdl 
wsdl2java - Apache CXF 2.3.2 

[Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces are required between publicId and systemId. 

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : https://server/app/services/MyService?wsdl 
Caused by : WSDLException (at /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 

org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : https://server/app/services/MyService?wsdl 
Caused by : WSDLException (at /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 
     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:288) 
     at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) 
     at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) 
     at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) 
     at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184) 
Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : https://server/app/services/MyService?wsdl 
Caused by : WSDLException (at /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 
     at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97) 
     at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69) 
     at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84) 
     at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61) 
     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:170) 
     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:137) 
     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:280) 
     ... 4 more 
Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 
     at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source) 
     at com.ibm.wsdl.xml.WSDLReaderImpl.parseImport(Unknown Source) 
     at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source) 
     at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) 
     at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) 
     at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:237) 
     at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186) 
     at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78) 
     ... 10 more 
Caused by: org.xml.sax.SAXParseExceptionpublicId: http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl; systemId: http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl; lineNumber: 1; columnNumber: 50; White spaces are required between publicId and systemId. 
     at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) 
     at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) 
     ... 18 more 

回答

0

原來的服務實現mypackage.MyServiceImpl是缺少javax.jws.WebService註解。

一旦包括在適當的serviceNameportNametargetNamespaceendpointInterface屬性,部署不<wsdl:import>服務。我懷疑這主要與targetNamespace屬性有關。

但是,外部XSD仍然以http地址引用,如<xsd:import schemaLocation="http://server:80/app/schema/myschema.xsd">。我在原始WSDL中引用了它們。對我來說,唯一的解決方案是在原始WSDL中內聯所有XSD定義。