Spring WS WSDL自动曝光:不遵循xsd导入(Spring WS WSDL automatic exposure : xsd import are not followed)
我正在尝试基于多个xml架构为Spring WS Web服务动态生成WSDL。 我有一个多个xsd文件,所有这些文件都是使用xsd:import元素“连接”的。
Spring WS参考说:
如果要使用包含或导入的多个模式,则需要将Commons XMLSchema放在类路径上。 如果Commons XMLSchema在类路径上,则上述元素将遵循所有XSD导入和包含,并将它们作为单个XSD在WSDL中内联。 这极大地简化了模式的部署,这仍然可以单独编辑它们。
所以我添加了这个maven依赖:
<dependency> <groupId>org.apache.ws.xmlschema</groupId> <artifactId>xmlschema-core</artifactId> <version>2.2.1</version> </dependency>
并以这种方式配置WSDL构建器:
@Bean(name="updateContactService") public DefaultWsdl11Definition defaultWsdl11Definition() throws Exception { DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); wsdl11Definition.setPortTypeName("updateContactPort"); wsdl11Definition.setLocationUri("/ws/updateContact"); wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); wsdl11Definition.setSchema(updateContactXsd()); return wsdl11Definition; } @Bean public XsdSchemaCollection updateContactXsd() throws Exception { return new SimpleXsdSchema(new ClassPathResource("xsds/contact/outboundMessage.xsd")); }
但生成的WSDL只包含一个架构元素(并显示导入错误的位置)。
<xs:import namespace="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/" schemaLocation="personService.xsd"/>
有小费吗? Spring WS版本是2.3.1
<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://spring.io/guides/gs-producing-web-service" targetNamespace="http://spring.io/guides/gs-producing-web-service"> <wsdl:types> <xs:schema xmlns="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:ns2="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/" xmlns:tns0="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/"> <xs:import namespace="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/" schemaLocation="personService.xsd"/> <xs:element name="process" type="tns0:processType"/> <xs:complexType name="processType"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="Person" type="ns2:Person"/> </xs:sequence> </xs:complexType> <xs:element name="processResponse" type="tns0:processResponseType"/> <xs:complexType name="processResponseType"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="Person" type="ns2:Person"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="processResponse"> <wsdl:part element="sch:processResponse" name="processResponse"> </wsdl:part> </wsdl:message> <wsdl:portType name="updateContactPort"> <wsdl:operation name="process"> <wsdl:output message="tns:processResponse" name="processResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="updateContactPortSoap11" type="tns:updateContactPort"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="process"> <soap:operation soapAction=""/> <wsdl:output name="processResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="updateContactPortService"> <wsdl:port binding="tns:updateContactPortSoap11" name="updateContactPortSoap11"> <soap:address location="https://localhost:4440/ws/updateContact"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
I'm trying to dynamically generate WSDL for a Spring WS web service, based on multiple xml schemas. I have a multiple xsd files, all of them are "connected" using xsd:import elements.
Spring WS reference says :
If you want to use multiple schemas, either by includes or imports, you will want to put Commons XMLSchema on the class path. If Commons XMLSchema is on the class path, the above element will follow all XSD imports and includes, and will inline them in the WSDL as a single XSD. This greatly simplifies the deployment of the schemas, which still making it possible to edit them separately.
so I added this maven dependency :
<dependency> <groupId>org.apache.ws.xmlschema</groupId> <artifactId>xmlschema-core</artifactId> <version>2.2.1</version> </dependency>
and configurated the WSDL builder in this way :
@Bean(name="updateContactService") public DefaultWsdl11Definition defaultWsdl11Definition() throws Exception { DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); wsdl11Definition.setPortTypeName("updateContactPort"); wsdl11Definition.setLocationUri("/ws/updateContact"); wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); wsdl11Definition.setSchema(updateContactXsd()); return wsdl11Definition; } @Bean public XsdSchemaCollection updateContactXsd() throws Exception { return new SimpleXsdSchema(new ClassPathResource("xsds/contact/outboundMessage.xsd")); }
but the generated WSDL only contains a single schema element (and showing the import with a wrong location).
<xs:import namespace="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/" schemaLocation="personService.xsd"/>
Any tips? Spring WS version is 2.3.1
<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://spring.io/guides/gs-producing-web-service" targetNamespace="http://spring.io/guides/gs-producing-web-service"> <wsdl:types> <xs:schema xmlns="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:ns2="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/" xmlns:tns0="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/"> <xs:import namespace="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/" schemaLocation="personService.xsd"/> <xs:element name="process" type="tns0:processType"/> <xs:complexType name="processType"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="Person" type="ns2:Person"/> </xs:sequence> </xs:complexType> <xs:element name="processResponse" type="tns0:processResponseType"/> <xs:complexType name="processResponseType"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="Person" type="ns2:Person"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="processResponse"> <wsdl:part element="sch:processResponse" name="processResponse"> </wsdl:part> </wsdl:message> <wsdl:portType name="updateContactPort"> <wsdl:operation name="process"> <wsdl:output message="tns:processResponse" name="processResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="updateContactPortSoap11" type="tns:updateContactPort"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="process"> <soap:operation soapAction=""/> <wsdl:output name="processResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="updateContactPortService"> <wsdl:port binding="tns:updateContactPortSoap11" name="updateContactPortSoap11"> <soap:address location="https://localhost:4440/ws/updateContact"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
原文:https://stackoverflow.com/questions/42112775
满意答案
在js文件中
app.service('mainService',function ($http,$q) { this.login = function (userInfo) { var defer = $q.defer(); $http.post( 'http://localhost/login.php', {user: userInfo}, {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}} ) .success(function (response) { $scope.names = response.records; if(res){ defer.resolve(response); }else{ defer.reject(response); } }) .error(function (err) { defer.reject(err); }) return defer.promise } });
在PHP的服务器端
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Access-Control-Allow-Headers, accept");
in the js file
app.service('mainService',function ($http,$q) { this.login = function (userInfo) { var defer = $q.defer(); $http.post( 'http://localhost/login.php', {user: userInfo}, {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}} ) .success(function (response) { $scope.names = response.records; if(res){ defer.resolve(response); }else{ defer.reject(response); } }) .error(function (err) { defer.reject(err); }) return defer.promise } });
and on the server side in php
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Access-Control-Allow-Headers, accept");
相关问答
更多关于msql和mysql
PHP的MySQL共享数据到MSQL(php mysql share data to msql)
PHP / MSQL:用户注册页面(PHP / MSQL : User Sign Up Page)
MSQL JOIN:我无法显示类别列表(MSQL JOIN: I cant show a list of categories)
phonegap / msql(i)无法建立与数据库的连接(phonegap/msql(i) can't establish connection to database)
使用msql fetch填充php数组(Fill php array with msql fetch)
将PHP POST变量更改为msql数据库的日期格式(change PHP POST variable into date format for msql database)
如何使用msql检查两个字段是否具有相同的值?(How to check if two fields have same value using msql?)
离子2用php msql(ionic 2 with php msql)
使用PHP从MSQL查询创建HTML表,没有重复的行?(use PHP to create an HTML table from a MSQL query, without duplicate rows?)
相关文章
更多Spring Project Annotations
使用Solr Data Import的delta-import功能
(二)solr data import
Spring与工厂模式
Httpclient整合Spring教程
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!