Should look like a stupid question, but I have the following problem.
There's an external web service, WSDL is available. My task is to call it's methods from another enterprise application (running on WebSphere 8.5)
Using Rational Application Developer, I generated Web service client classes into the application's project, specifying the application's package, which DIFFERS from the web service's one. Web service's method returns a POJO, which is a wrapper for ArrayList.Then I make a call to web service, using generated calsses in the following way:
package com.mycompany.services.external;
import com.mycompany.services.external.client.SomeCommonService;
import com.mycompany.services.external.client.SomeCommonServiceService;
import com.mycompany.services.external.client.IdsList;
final QName COMMONSERVICE_QNAME = new QName("http://webService.othercompany.com/", "SomeCommonServiceService");
String strUrl = "http://....";
String query = "/universal [#Barcode=\"000111\"]";
URL serviceUrl = new URL(strUrl);
SomeCommonServiceService service=new SomeCommonServiceService(serviceUrl, COMMONSERVICE_QNAME);
SomeCommonService port = service.getSomeCommonServicePort();
IdsList itemsIds = port.getItemsIdsByQuery(query);
And as a result the last line of code, where the method is invoked, causes an error:
[1/17/17 21:55:39:758 MSK] 00000497 SystemErr R CIWEB Error:
[admin(unknown) # 10.253.32.24]
com.ibm.ecm.util.PluginUtil.invokeService()
javax.xml.ws.WebServiceException: javax.xml.bind.JAXBException:
com.mycompany.services.external.client.IdsList is not known to this
context
Taking a look into the generated package-info.java the following mapping can be seen:
#javax.xml.bind.annotation.XmlSchema(namespace = "http://webService.othercompany.com/")
package com.mycompany.services.external.client;
If I leave original option (not changing default package) while generating client - the same problem and the same error. But in this case, if I pack generated client into a separate JAR and use it as a shared library for my application on WebSphere server - then all works fine! But that's not acceptable for some reasons.
Could somebody be so pleasant to hepl me solve the problem?
I used to work with Web Services Base on WSDL:
Example: http://www.dgii.gov.do/wsMovilDGII/WSMovilDGII.asmx?wsdl
Of course using MAVEN, I use this pluging
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.5</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java/</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>http://www.dgii.gov.do/wsMovilDGII/WSMovilDGII.asmx?wsdl</wsdl>
<packagenames>
<packagename>com.hectorvent.consultadgii</packagename>
</packagenames>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Related
I'm trying to generate 2 controller classes for 2 scopes in my project.
I can do that with 2 separate openapi.yaml files, and 2 maven executions.
I'm using swagger-codegen-maven-plugin to get it done, and I could only find code that uses swagger.yaml or openapi.yaml with a different plugin.
I can't find this combination, though I'm positive it's possible.
The question is if I have 2 scopes such as 'DB' and 'Browse', and I want to have 2 interfaces created for the 2 scopes such as DBApi.java and BrowseApi.java, how can it be done, and if it can be done using 1 openapi.yaml file?
I did see example projects where 1 openapi.yaml file resulted in PetApi.java and StoreApi.java, but I couldn't find how to configure this in my setup.
Thanks.
The relevant part in the maven pom file is:
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<executions>
<execution>
<id>raptor-codegen</id>
<configuration>
<apiPackage>com.app.seo.graph.rest.v1.api</apiPackage>
<modelPackage>com.app.seo.graph.rest.v1.model</modelPackage>
<inputSpec>${project.basedir}/src/main/resources/api/openapi.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
<additional-properties>preAuthorize=hasAuthority,useJsonPropertyOrder=true,resourceMetaType=com.ebay.jaxrs.server.ResourceOperation</additional-properties>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
I've used <useTags>true</useTags> under <configOptions> in my Maven file and it works for me. YAML definition
paths:
'/operation/':
get:
tags:
- Some-Service
generates "SomeServiceApi" class name with the SpringCodegen generator. Using "openapi-generator-maven-plugin" in the "6.2.0" version.
I have a multi module spring-boot project, before integration tests of my app, I start another child module (which is Stub made by another spring boot app) You can see it is attached to "pre-integration-test" and it is working fine finally.
Parent Pom
|
|----myRealApp module(spring boot app)
|----stub module(This is also a spring-boot app)
My question is, is there a way to randomize And share this port (not fixed to 8090), so concurrent builds on Jenkins server can run tests and not fail because address is in use already.
I know I can generate random numbers/ports in spring properties file. But couldn't find a way to pass it to Pom.
application-test.properties of myRealApp:
stub.port=8090
stub.url=http://localhost:${stub.port}/stub/api/v1/domains/
Pom of myRealApp:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${spring.boot.mainclass}</mainClass>
</configuration>
<executions>
<execution>
<id>start-stub</id>
<configuration>
<arguments>
<argument>--server.port=8090</argument>
</arguments>
<mainClass>io.swagger.Stub</mainClass>
<classesDirectory>../my-stub/target/classes</classesDirectory>
</configuration>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
You can do that via jenkins Port Allocator Plugin
Once you assign the port (lets say HTTP_PORT), then you can pass this as command line
-Dstub.port=$HTTP_PORT
I recommend you not to randomize at all. My suggestion is to parametrize the server port in the POM and application-test.properties files, and set a value based upon some Jenkins-provided variable: For example, BUILD_NUMBER, which is incremented on every build and thus uniqueness is guranteed.
However, there is a problem about this: You also need to enclose the port number within valid boundaries: TCP ports must be within 1024 and 65535, however BUILD_NUMBER is not limited at all.
How to cope with this? I think a simple Ant task bound to the initialize phase could read the BUILD_NUMBER value, apply it a simple formula 1024+(BUILD_NUMBER % 64512), and set it as the definitive port number variable, which is the one you will reference in the POM and application-test.properties files.
I've inherited a project that contains many java web services. I want to add another one so I've been using one that works as a template. I've added
<namespace id="bsghandle"
uri="http://bsghandle.queryservice.vcwh.oss.cable.company.com/" />
into the <namespaces> section of enunciate.xml and
namespace="http://bsghandle.queryservice.vcwh.oss.cable.company.com/"
file="bsghandle.wsdl" />
into the <xml> section.
Here is the pom.xml snippet
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.25</version>
<configuration>
<configFile>${basedir}/src/main/webapp/WEB-INF/enunciate.xml</configFile>
<compileDebug>true</compileDebug>
<addGWTSources>false</addGWTSources>
<addActionscriptSources>false</addActionscriptSources>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
Maven generates the web.xml entries, including this one:
<filter-mapping>
<filter-name>wsdl-redirect-filter-bsghandle</filter-name>
<url-pattern>/soap/BsgHandleResourceService</url-pattern>
</filter-mapping>
I created three classes to handle the request, similar to the template.
I send a request to the working service like this
./soapget.sh soap_serial.xml r.xml
where soapget.sh is
#!/bin/bash
wget "http://localhost:5032/VCWH_QueryService/soap/SettopChannelMapResourceService" --post-file=$1 --header="Content-Type: text/xml" -O $2
This produces a good response, captured in r.xml.
Now when I try the same thing for the new service I wrote
./bsg.sh soap_rate.xml r2.xml
where bsg.sh is
#!/bin/bash
wget "http://localhost:5032/VCWH_QueryService/soap/BsgHandleResourceService" --post-file=$1 --header="Content-Type: text/xml" -O $2
I get the useless error
2015-11-23 20:26:52 ERROR 500: Internal Server Error
The log files for the project do not contain any more info either.
When I watch the log file for the working service (in SettopChannelMapResource.java), I can see this debugging statement getting hit as the first thing being output to the log
logger.debug("getChannelMapBySerialNumber() called for sn=" + serialNumber
+ " from ip" + request.getRemoteAddr());
But in my similar service the same logger output does not get hit.
How do I debug this?
I used a request in SoapUI. For some reason, that returned a useful error message and I was able to find and fix the problem. Even after fixed, the other method still returned the same useless ERROR 500: Internal Server Error
Using this maven plugin, I was able to generate my classes and reused them in another schema; which is really great!
Now I find myself with a schema needing two episodes (two different packages generated from schemas). I simply tried to add another arg in XJC, but it didn't work.
Then I changed the order of the two args, and the error targetted the other schema. I then understood that both episodes were OK, but it might not be the way of doing things.
Here is some of my pom:
<execution>
<id>business</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
..
<extension>true</extension>
<args>
<arg>-b</arg>
<arg>${project.basedir}/target/episodes/x.episode</arg>
<arg>${project.basedir}/target/episodes/y.episode</arg>
<arg>${project.basedir}/target/episodes/z.episode</arg>
</args>
..
</configuration>
</execution>
And here is what I get:
org.xml.sax.SAXParseException; systemId: file:/****.episode; lineNumber: 2; columnNumber: 65; s4s-elt-schema-ns: namespace element 'bindings' must be from 'http://ww.w3.org/2001.XMLSchema'.
From what I understand (after swapping their call in ), the three schemas/episodes are good, but I cannot use them both at the same time. Any way to do that?
Newbie here, any help much appreciated :).
Author of the maven-jaxb2-plugin here.
Why do you use args, why not just add your episodes in the configuration?
<episodes>
<episode>
<groupId>com.acme.foo</groupId>
<artifactId>package1</artifactId>
<!-- Version is not required if the artifact is
configured as dependency -->
</episode>
<episode>
<groupId>com.acme.foo</groupId>
<artifactId>package2</artifactId>
<!-- Version is not required if the artifact is
configured as dependency -->
</episode>
</episodes>
The whole idea of episodes is that you can point to the JAR (containing the episode file) and XJC will find out and use the binding from the contained episode. Using arg with -b is not what it was inteded for. :)
Concerning the error you're seeing, I guess the way you configure arg makes XJC think that your second and further episodes are actually schemas. I'd try to put intermediate -b arguments or configure all the episodes you refer to in one arg.
But I still think it is not the right way to use episodes. Compile your episodes as separate JARs/separate Maven modules, use them as dependencies and either configure them as episodes or just turn on the useDependenciesAsEpisodes option.
I have done this before on another project. I think you're using the wrong syntax:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>jaxb-Generic-XSD</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<enableIntrospection>false</enableIntrospection>
<schemaFiles>Generic.xsd</schemaFiles>
<schemaDirectory>${jaxb.schema.folder}</schemaDirectory>
<packageName>you.package.name.here</packageName>
<outputDirectory>${jaxb.output.folder}</outputDirectory>
<extension>true</extension>
<arguments>-b ${core.episode.file} -b ${containers.episode.file}</arguments>
</configuration>
</execution>
</executions>
</plugin>
Note the: <arguments>-b ${core.episode.file} -b ${containers.episode.file}</arguments> line.
I think you're using the same maven plugin, but if not, then take note of the plugin version groupId, artifactId, and use it instead.
I'm writing a server that embeds Jetty w/ Jersey. When I execute from Eclipse, everything is great. However, if I assemble my server and all dependencies into a single jar using Maven's assembly:single goal, I get an exception:
Sep 26, 2012 5:35:59 PM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: A message body writer for Java class com.acme.server.webservice.
exception.WebServiceFailure, and Java type class com.acme.server.webserv
ice.exception.WebServiceFailure, and MIME media type application/json was not fo
und
Sep 26, 2012 5:35:59 PM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: The registered message body writers compatible with the MIME media type
are:
*/* ->
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
17:35:59.372 [qtp184245201-22 - /] ERROR o.a.h.ReflectorServletProcessor - onReq
uest()
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A mess
age body writer for Java class com.acme.server.webservice.exception.WebS
erviceFailure, and Java type class com.acme.server.webservice.exception.
WebServiceFailure, and MIME media type application/json was not found
at com.sun.jersey.spi.container.ContainerResponse.write(ContainerRespons
e.java:285) ~[vma-server-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequ
est(WebApplicationImpl.java:1457) ~[server-0.0.1-SNAPSHOT-jar-with-dependenc
ies.jar:na]
...
The full trace is here, if it's useful:
https://gist.github.com/3790817
Maven throws no errors while creating the jar-with-dependencies.
I'm a novice with Maven and deployment of Java, and I'm really not sure how to proceed with debugging.
Also, while I need to solve this issue I'd also appreciate any suggested work-arounds as I need to produce an executable demo of my server ASAP that a Pointy-Haired Boss (tm) can execute without Eclipse.
Solution:
Based on Pavel's answer, I dropped the maven-assemly-plugin in favor of maven-shade-plugin. Here's the shade configuration that worked for me:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- use transformer to handle merge of META-INF/services - see http://java.net/jira/browse/JERSEY-440?focusedCommentId=14822&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_14822 -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
<filters>
<!-- filter to address "Invalid signature file" issue - see http://stackoverflow.com/a/6743609/589215-->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
You are not merging Jersey jars correctly.
Jersey 1.x uses META-INF/services mechanism to discover its components and assembly:single probably just copies everything into single jar, overriding already present files BUT META-INF/services file(s) needs to be CONCATENATED.
Try using jersey-bundle (com.sun.jersey:jersey-bundle:1.14) or fix your assembly settings (or find another plugin to do it better).
Could you post your pom ?
Do you mark some dependencies as provided ?
It's something quite different to build a standalone app and a webapp, as some jars a supposed to be provided by the web container (tomcat or other).
As your container is "embedded" in your app (and not your app in the container) then maybe you don't manage correctly these dependencies.