有人可以向我解释一下CXF的以下行为吗?
我有简单的WebService:
import javax.jws.WebMethod;
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
@WebMethod(exclude = true)
String methodToExclude(String s);
}
Run Code Online (Sandbox Code Playgroud)
我想拥有我的methodToExcludein接口(对于Spring),但我不想在生成的WSDL文件中使用此方法.上面的代码确实如此.
但是当我@WebService向界面添加注释时,我得到错误:
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
@WebMethod(exclude = true)
String methodToExclude(String s);
}
Run Code Online (Sandbox Code Playgroud)
org.apache.cxf.jaxws.JaxWsConfigurationException:@ javax.jws.WebMethod(exclude = true)不能在服务端点接口上使用.方法:methodToExclude
谁可以给我解释一下这个?有什么不同?此外,我不确定它是否会在以后工作正常,但我没有找到如何排除methodToExclude我使用时的方式@WebService.
我的应用程序服务无法启动或响应甚至预热请求,因为Jersey扫描库所花费的时间过长.
我创建了应用程序并硬编码了泽西资源的所有路径.
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.livily.rest.JerseyApplication</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)
泽西应用程序有所有类
public Set<Class<?>> getClasses()
{
Set<Class<?>> s = new HashSet<Class<?>>();
s.add(com.livily.rest.visitor.UserRatingUtil.class);
}
Run Code Online (Sandbox Code Playgroud)
然而,球衣正在扫描许多提供商
Mar 8, 2013 3:39:40 PM com.sun.jersey.core.spi.component.ProviderServices getServiceClasses
CONFIG: Provider found: class com.sun.jersey.server.impl.model.parameter.multivalued.StringReaderProviders$StringConstructor
Run Code Online (Sandbox Code Playgroud)
它正在做大约50-100次然后
Mar 8, 2013 3:39:41 PM com.sun.jersey.server.impl.modelapi.annotation.IntrospectionModeller createResource
FINEST: A new abstract resource created by IntrospectionModeler: AbstractResource("/current-status", - CurrentStatus: 1 constructors, 0 fields, 0 setter methods, 1 res methods, 0 subres methods, 0 subres locators )
Run Code Online (Sandbox Code Playgroud)
每一个人
总共花费的时间约为4-10秒,而appengine不喜欢这样,因为它希望快速包裹装载; 否则它开始给出奇怪的500错误(甚至是静态文件).
我很难过; 任何帮助将不胜感激.
在我的工作中使用jaxws-maven-plugin进行代码生成.我有两个项目是"普通"和"客户".结构大致如下:
app/
common/
resource/
some.xsd
client/
resource/
some.wsdl
Run Code Online (Sandbox Code Playgroud)
如何使用项目"common"中的xsd在项目"client"中从wsdl生成类?
pom.xml中:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<verbose>true</verbose>
<bindingFiles>
<bindingFile>${project.parent.basedir}/common/resource/some.xsd</bindingFile>
</bindingFiles>
<wsdlFiles>
<wsdlFile>/resource/some.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 使用javaws我们可以有多个端点导致相同的方法.例:
@Path("/menus")
public class MenuResource {
@Path("/{menuId}/sections")
@Timed @ExceptionMetered
public MenuSectionResource getSections(@InjectParam MenuSectionResource resource) {
return resource;
}
}
@Path("/sections")
public class MenuSectionResource {
@GET
public Section get(@PathParam("menuId") String menuId, @QueryParam("id") String id) {
../// method accessed by GET in /sections or GET in /menus/{menuid}/sections
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用招摇来记录两个端点,但我只能@Api在每个类中使用一个
注释,所以我可以生成/sections或者/menus/{menuid}/sections.是否可以在swagger.json输出中自动生成两个条目?
我正在使用jaxws-maven-plugin的wsimport目标从WSDL生成Java类.开箱即用,这会从XML模式生成可怕的类和方法; 例如,来自名为MY_OBJECT的XML元素的名为MYOBJECT的类.
我发现我可以使用外部文件自定义JAXB2绑定 ; 这对于少数类和方法是可以接受的,但是在这种情况下手动命名所有内容的开销是不合需要的.
一些搜索揭示了对XJC CamelCase Always插件的引用,但这似乎没有维护,大多数链接都是404.不愿意放弃,我确实找到了一个似乎提供此功能的camelcase-always Maven工件,但我不知道如何配置它以便jaxws-maven-plugin使用它.
如何在不指定全部手动的情况下获取CamelCase绑定?
我有一个PHP的Web服务构建,它使用UsernameToken作为身份验证机制.我有PHP客户端代码可以访问此Web服务.现在我需要用Java做到这一点.也许你可以帮助我!
可以使用以下php代码访问此服务:
$password="super_secure_pass";
$timestamp=gmdate('Y-m-d\TH:i:s\Z');
$nonce=mt_rand();
$passdigest=base64_encode(pack('H*',sha1(pack('H*',$nonce).pack('a*',$timestamp).pack('a*',$password))));
$nonce=base64_encode(pack('H*',$nonce))
Run Code Online (Sandbox Code Playgroud)
这些值被解析为此Soap头.
<wsse:Security SOAP-ENV:mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>'.$username.'</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">'.$passdigest.'</wsse:Password>
<wsse:Nonce>'.$nonce.'</wsse:Nonce>
<wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'.$timestamp.'</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
Run Code Online (Sandbox Code Playgroud)
使用此代码,我可以毫无问题地访问Web服务.现在我需要用Java做到这一点.
我创建了必要的文件,实现了一个处理程序来添加一个带有UsernameToken的soap标头.但是当我尝试访问WS时,我总是收到"Not Authorized"错误.我认为在创建passdigest或nonce条目时我遗漏了一些东西.
以下是我如何计算它们:
Random generator = new Random();
String nonceString = String.valueOf(generator.nextInt(999999999));
String createTime=localToGmtTimestamp();//Returns a date with format (SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"))
String pass="super_secure_pass";
String tmp = AeSimpleSHA1.SHA1(nonce + createTime + pass);
encodedPass = Base64.encodeBytes(tmp.getBytes());
Run Code Online (Sandbox Code Playgroud)
创建soap标头时将使用这些值:
SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope();
SOAPHeader header = envelope.addHeader();
SOAPElement security = header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
SOAPElement usernameToken = security.addChildElement("UsernameToken", "wsse");
SOAPElement username = usernameToken.addChildElement("Username", "wsse");
username.addTextNode(user);
SOAPElement …Run Code Online (Sandbox Code Playgroud) 我正在尝试调用Java Webstart,它使用"-open"运行时选项将参数发送到webstart应用程序.我引用了这个问题:将命令行参数传递给javaws(Java WebStart)可执行文件,但是这种语法似乎不适用于多个参数.它似乎可以找到一个参数.
当我运行"javaws URLtoMyJNLP"时,它运行应用程序很好,当我通过"javaws -open arg URLtoMyJNLP"发送单个参数时,它似乎也工作,并且arg到达应用程序.当我尝试运行"javaws -open arg arg arg arg URLtoMyJNLP"时,它表示提供了无效的参数.我在ProcessBuilder.command中输入命令.
InvalidArgumentException[ Invalid arguments supplied: {hello, jnlp, launch.jnlp, 123 }]
Run Code Online (Sandbox Code Playgroud)
对于上面的输出我尝试发送"javaws -open abc 123 hello launch.jnlp"
有任何想法吗?
代码请求.由于是PoC,它过于简单化了.
private static void launchApp(String appName, String appPath, String... args)
{
logger.debug("Launching application: " + appName);
Properties props = System.getProperties();
ArrayList<String> fullCmdString = new ArrayList<String>();
logger.debug("http://" + System.getProperty("jnlp.serverip") + ":" + System.getProperty("jnlp.serverport") + "/FB2HMI/" + appPath);
if (args.length > 0)
{
fullCmdString.add("javaws");
fullCmdString.add("-open");
}
for (String arg : …Run Code Online (Sandbox Code Playgroud) 我正在使用Apache CXF 2.7.3,并遇到一个我真的不明白的命名空间问题.我已经尝试过广泛搜索,但我找到的大部分结果都是针对不同的行为.问题是在调用Web服务时,如果参数元素是名称空间限定的,它将失败.消息中的所有其他元素都是合格的,它接受它,而不是参数元素.这是精确的行为:
请求WITHOUT参数元素限定:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ord="http://www.example.org/order">
<soapenv:Header/>
<soapenv:Body>
<ord:getOrder>
<id>a</id>
</ord:getOrder>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
结果成功:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getOrderResponse xmlns:ns2="http://www.example.org/order">
<return>
<ns2:errorCode/>
<ns2:errorMessage/>
<ns2:order>
<ns2:orderNumber>ABC123</ns2:orderNumber>
<ns2:lastName>Smith</ns2:lastName>
</ns2:order>
</return>
</ns2:getOrderResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
请求WITH参数限定:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ord="http://www.example.org/order">
<soapenv:Header/>
<soapenv:Body>
<ord:getOrder>
<ord:id>a</ord:id>
</ord:getOrder>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
导致JAXB异常:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"http://www.example.org/order", local:"id"). Expected elements are <{}id></faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
在我所做的所有研究中,这通常意味着命名空间在某处不匹配.但是我已经彻底检查了它,并且命名空间在任何地方都是相同的,包括ObjectFactory.class,package-info.class和cxf-servlet.xml配置文件以及@WebService注释.任何人都可以指出我正确的方向,我在这里失踪了什么?
美好的一天.我正在学习如何编写连接到外部SOAP RCP样式的服务.我正在使用jaxws-maven-plugin插件从WSDL文件生成Java类.我正在使用Spring来创建Web服务客户端bean:
@Configuration
public class StoreServiceConfig {
@Bean
public StoreWS storeWS() throws IOException {
JaxWsPortProxyFactoryBean factoryBean = new JaxWsPortProxyFactoryBean();
factoryBean.setServiceInterface(StoreWS.class);
factoryBean.setWsdlDocumentUrl(new ClassPathResource("/wsdl/StoreWS.wsdl").getURL());
factoryBean.setNamespaceUri("urn_store");
factoryBean.setServiceName("StoreWSService");
factoryBean.setEndpointAddress("https://10.34.45.82/storeservice/services/StoreWS");
factoryBean.setUsername("testuser");
factoryBean.setPassword("testpassword");
factoryBean.afterPropertiesSet();
return (StoreWS) factoryBean.getObject();
}
}
Run Code Online (Sandbox Code Playgroud)
为了测试客户端,我使用JUnit编写了一个测试类.我用这种方式打电话给客户:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = StoreServiceTestConfig.class)
public class StoreServiceImplTest {
@Autowired
private StoreWS storeWS;
...
@Test
public void testExecuteQuery() throws Exception {
...
StoreResponseType response = storeWS.executeQuery(storeRequest);
...
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我需要测试将完整的传出和传入SOAP消息记录到控制台中.请问怎么做?越简单越好.
我找到了使用以下系统参数的建议,但它们都不适用于我:
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
com.sun.xml.ws.transport.local.LocalTransportPipe.dump=true
com.sun.xml.ws.transport.http.HttpAdapter.dump=true
Run Code Online (Sandbox Code Playgroud)
我正在使用Spring配置类(没有XML)和所有依赖项的最新版本.
我找到了这个答案,但我不知道如何在我的场景中使用它.
提前谢谢了!Vojtech
编辑: 我的logback.xml看起来像这样,但我仍然看不到控制台中的任何肥皂消息:
<?xml version="1.0" encoding="UTF-8"?> …Run Code Online (Sandbox Code Playgroud)