我正在尝试使用jax-ws来生成Web服务代理类,使用wsimport ant任务,类似于这个问题,使用以下后续问题:
据我了解,更新版本的JDK 1.6包括jax-ws,而WsImport ant任务在JDK的tools.jar文件中定义.
为什么蚂蚁不会自动找到这个?
为什么eclipse也不会自动找到这个?
我发现使用JAX-WS与JDK 6几的引用,但这些似乎是基于复制单独下载JAX-WS库,并将其拖放到JDK ext文件夹(我假设不再需要因为它实际上是现在与JDK捆绑在一起).
将wsimport任务与已包含jax-ws的JDK 1.6版本一起使用的正确方法是什么?
我的构建XML:
<?xml version="1.0" encoding="UTF-8"?>
<project name="wsproxy">
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" />
<target name="wsgentest">
<wsimport
wsdl="http://localhost/Service?wsdl"
destdir="bin-gen"
sourcedestdir="src-gen"
keep="true"
verbose="true"
package="com.ws">
</wsimport>
</target>
</project>
Run Code Online (Sandbox Code Playgroud) 我花了一整天时间寻找一个解决方案来解决如何让wsgen + maven从我的注释类中生成工件而无济于事,总是以"找不到类文件"错误结束.
我的pom.xml如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsgen</goal>
</goals>
</execution>
</executions>
<configuration>
<sei>fr.extelia.ibabi.ws.convergence.impl.ServiceWSConvergence</sei>
<keep>true</keep>
<verbose>true</verbose>
<sourceDestDir>target/generated-sources/artifacts</sourceDestDir>
<packageName>fr.extelia.ibabi.ws.convergence.stub</packageName>
</configuration>
<dependencies>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
<version>1.0-MR1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.5</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
此外,我尝试在命令行生成工件,没有更好的结果:
wsgen -cp C:\workspace\ibabi\trunk\ibabi-ws\ibabi-ws-service\target\classes -keep -s C:/workspace/ibabi/trunk/ibabi-ws/ibabi-ws-service/target/generated-sources/artifacts fr.extelia.ibabi.ws.convergence.impl.ServiceWSConvergence
Run Code Online (Sandbox Code Playgroud)
PS:我在命令行使用"classes"文件夹作为端点类的位置.使用src文件夹只会返回命令行输入描述的错误.
对此有任何帮助真的很感激
谢谢
我有一个Web应用程序,它充当使用Spring WS实现的Jax-WS Web服务的客户端.Spring WS配置为在SOAP标头中需要用户名标记.在Web应用程序中,我计划使用Spring Web服务模板,但我似乎找不到任何显示如何将UsernameToken添加到传出请求的示例.
有人能指出我正确的方向吗?
谢谢.
我正在从事网络服务.我想知道如何在JAX-WS类型的Web服务中向SOAP请求添加标头.
考虑我的头像这样.
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("aaaa"));
headers.put("Password", Collections.singletonList("aaaa"));
Run Code Online (Sandbox Code Playgroud)
我的客户端类中有stub对象.我正在使用Apache Axis 2.所有类都是自动生成的.
SimpleSTub stub = new Simplestub();
Run Code Online (Sandbox Code Playgroud)
我想在客户端添加此标头信息.
MessageContext.HTTP_REQUEST_HEADERS, headers
Run Code Online (Sandbox Code Playgroud)
编辑
在普通类中的实际实现发现为
private static final String WS_URL ="http:// localhost:9999/ws/hello?wsdl";
public static void main(String [] args)throws Exception {
URL url =新URL(WS_URL); QName qname = new QName("http://ws.mkyong.com/","HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
/*******************UserName & Password ******************************/
Map<String, Object> req_ctx = ((BindingProvider)hello).getRequestContext();
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, WS_URL);
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("mkyong"));
headers.put("Password", Collections.singletonList("password")); …Run Code Online (Sandbox Code Playgroud) 我一直使用 wsimport 工具从 WSDL 文件生成客户端类。然后我将它们包含到项目的源代码树中,并将它们检入版本控制系统。但是最近我了解到有一个 maven 插件,叫做 jaxws-maven-plugin,它可以生成客户端类作为构建步骤(mvn clean jaxws:wsimport)。
虽然我不清楚使用这个插件的真正好处是什么,除了不需要将 WS 客户端类检查到源代码控制中。尽管如此,如果有人想在该项目上工作,他必须检查代码,然后运行 mvn jaxws:wsimport,然后才能开始工作(否则 IDE 将显示错误)。那么真正的好处是什么,什么时候应该使用插件而不是将客户端代码签入 VCS?
我正在尝试将带有axis1.4 客户端的文件发送到jaxws 服务。我的客户端代码如下。
System.out.println(service.getCalcImplPort().getFile(new DataHandler(new DataSource() {
@Override
public OutputStream getOutputStream() throws IOException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return "abc.txt";
}
@Override
public InputStream getInputStream() throws IOException {
InputStream bs = new ByteArrayInputStream("Hello world".getBytes());
return bs;
}
@Override
public String getContentType() {
// TODO Auto-generated method stub
return "application/soap+xml";
}
})));
Run Code Online (Sandbox Code Playgroud)
当我从 tcpmon 中查看时,我看到生成了下面的消息。
------=_Part_0_1601756168.1386618236799
Run Code Online (Sandbox Code Playgroud)
内容类型:文本/xml;charset=UTF-8 内容传输编码:二进制内容 ID:
------=_Part_0_1601756168.1386618236799 内容类型:application/soap+xml 内容传输编码:二进制内容 ID:
你好世界------=_Part_0_1601756168.1386618236799--
XML 部分是
<?xml …Run Code Online (Sandbox Code Playgroud) 这似乎很容易,但似乎我无法在 Google 上找到答案。我需要在我的 webroot 文件夹中发送文件列表,类似于目录浏览。
我正在使用 Glassfish、JAX-RS.WS 和 genson 作为 POJO 编写器。
应用程序结构如下:
download
|- build
|- dist
|- src
|- web
| |- files
Run Code Online (Sandbox Code Playgroud)
下面是我的代码
@Path("home")
public class HomeResource {
@Context
private UriInfo context;
@GET
@Produces(MediaType.APPLICATION_JSON)
public String get() {
return System.getProperty("user.dir"); // ??? Any idea what should be in here?
}
}
Run Code Online (Sandbox Code Playgroud)
结果如下:
/usr/lib/glassfish/glassfish/domains/domain1/config
Run Code Online (Sandbox Code Playgroud)
我需要它指向
/sites/download/web/
Run Code Online (Sandbox Code Playgroud)
或者至少
/sites/download/
Run Code Online (Sandbox Code Playgroud)
因为我需要我的服务提供一个列表,例如:
/files/item.zip
/files/document.pdf
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗??
谢谢
我有
在bin目录中,productInfo featureInfo返回许多内容,但其中包括:
在我的server.xml中,在下<featureManager>有一个<feature>...</feature>for:
在Eclipse中,我右键单击WAR项目,转到New-> Other ...,然后选择Web Services-> Web Service。点击下一步。
现在,我有一个包含以下字段的对话框:
some.package.SomeWebService根据我的代码;它包含适当的@WebService注释等)<my WAR project><my EAR project>当我单击下一步时,收到以下警告:
该项目针对没有IBM WebSphere …
我有以下端点接口:
@WebService
public interface SEIWebService {
@WebMethod
@WebResult(name="CreateWorkOrderItemResponse")
CreateWorkOrderItemResponse createWorkItem(@WebParam(name = "CreateWorkOrderItemRequest")CreateWorkOrderItemRequest request);
}
Run Code Online (Sandbox Code Playgroud)
实施:
@WebService(endpointInterface = "com.someCompany.SEIWebService", portName = "SEIWebServices")
public class SEIWebServiceImpl implements SEIWebService{
@Override
public CreateWorkOrderItemResponse createWorkItem(CreateWorkOrderItemRequest request) {
CreateWorkOrderItemResponse response = new CreateWorkOrderItemResponse();
response.setResponseCode("Testing Create 2222");
response.addError("Error 1");
response.addError("Error 2");
return response;
}
Run Code Online (Sandbox Code Playgroud)
最后,响应对象的代码
public class CreateWorkOrderItemResponse {
private String responseCode = null;
private ArrayList<String> errorList = new ArrayList<String>();
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getResponseCode() {
return responseCode;
}
public …Run Code Online (Sandbox Code Playgroud) 我的任务是为更新操作编写Web服务,其中将对象列表传递给该方法.
@WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(List<MyObject> objects){
}
Run Code Online (Sandbox Code Playgroud)
MyObject类很简单.
@XmlRootElement(name="Object")
public class MyObject{
private String item1;
private String item2;
}
Run Code Online (Sandbox Code Playgroud)
现在问题陈述.当我查看此方法的SOAP请求(为我生成的SOAP UI)时,请求如下所示:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<arg0>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</arg0>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
但我希望它看起来像下面.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<Objects>
<Object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</Object>
<Object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</Object>
</Objects>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
有人可以请一下建议.提前致谢.