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[2023-11-13]
那才有可能我劝你还是打消这念头吧,一年半载学不了什么的。除非整天呆在家研究。劳动局也是为白领(有钱人)开的!!否责很难学会的。再说了 你家人愿意让你成天呆在家学电脑吗?如果边工作边学的话也不好找合适的工作啊,再说了 现在南方偏僻点的城市能找个“一周不超44小时的工作”几乎不可能。每个单位都不把《劳动法》放在眼里 -
PHP的MySQL共享数据到MSQL(php mysql share data to msql)[2023-01-25]
你可以简单地访问mysql数据库 you can simply give access to mysql db -
你在添加用户功能中犯了一个错误。 两个{已打开但只有一个}已关闭。 这就是为什么signUp是未定义的,因为它现在是adduser函数的一部分。 You have made a mistake in the add user function. Two { are opened but just one } is closed. Thats why the signUp is undefined because it is now a part of the adduser function.
-
尝试这个 你的桌面设计有误。 规格与汽车之间有另一张表。 比如car_apec_value会有carid,specid,value。 通过加入这三个表,您将得到您想要的结果,例如 $resultjoin = mysqli_query($connecDB,"SELECT 'cars'.'idcar', 'specs'.'spec' FROM cars LEFT JOIN car_apec_value ON cars'.idcar = 'car_apec_value'.'carid' where specs.s ...
-
除非你用拼写错误填充代码,否则你要混合两个完全独立的mysql库: $con=mysqli_connect($host, $username, $password, $dbnaam);// or die($db_error1); ^---note the presence of an 'i' 在其他脚本中: $result = mysql_query($sql) or die(mysql_error()); ^---note the LACK of an ...
-
简单的方法,可能不是最好的方式,但取决于场景将是: $index = 1; $arr = array(); while ($row = $stmt2->fetch()) { $arr[ $index ] = $row; $index++; } The simple way, which may not be the best way, but that depends on the scenario would be: $index = 1; $arr = array(); while ...
-
您需要使用strtotime()将数据转换为timestamp 。 date()需要第二个参数是一个timestamp值。 试用 - $dateRequired = date("Y-m-d", strtotime($dateRequired)); m / d / y或dmy格式的日期通过查看各个组件之间的分隔符来消除歧义:如果分隔符是斜线(/),则假定美国m / d / y; 而如果分隔符是破折号( - )或点(。),则假定欧洲的dmy格式。 You need to use strtotime() to ...
-
在fan_following列中使用FRED并在fan_following BOB fan_followed生成Add Me as Fan按钮。 在fan_following列中有BOB ,在fan_following有BOB ,产生了Remove fan按钮。 通过改变: if ($fan_following == "$user" && $fan_followed=="$username") 至: if ($fan_following == $fan_followed) ^ - « (我相信也应该注意 ...
-
离子2用php msql(ionic 2 with php msql)[2024-02-10]
在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': ... -
使用PHP从MSQL查询创建HTML表,没有重复的行?(use PHP to create an HTML table from a MSQL query, without duplicate rows?)[2023-01-09]
我可能会这样编码,可能不是唯一的方法,但应该基于我相信你试图实现的目标而工作。 请确保将“order by”添加到您的SQL查询中。 echo "