我正在使用webbevice soa,netbeans(jax-ws)我使用netbeans自动生成客户端,所有运行正常,但我看到wsdl总是在客户端运行时下载.
在生产中我不想暴露wsdl,我试图修改客户端不需要wsdl,所有我的意图都错了,我发现这个:
WebService_Service svc = new WebService_Service(
null,
new QName("http://www.example.com/ws", "WebService"));
WebService port = svc.getPort(WebService.class);
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://www.example.com/real_endpoint_url_goes_here");
Run Code Online (Sandbox Code Playgroud)
但是当第一行执行时我发现了这个例外:
Message: El contenido no está permitido en el prólogo.
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.wrapException(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextContent(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextElementContent(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.hasWSDLDefinitions(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
有什么想忽略wsdl?
我想要替换如下的java字符串值.下面的代码不起作用.
cleanInst.replaceAll("[<i>]", "");
cleanInst.replaceAll("[</i>]", "");
cleanInst.replaceAll("[//]", "/");
cleanInst.replaceAll("[\bPhysics Dept.\b]", "Physics Department");
cleanInst.replaceAll("[\b/n\b]", ";");
cleanInst.replaceAll("[\bDEPT\b]", "The Department");
cleanInst.replaceAll("[\bDEPT.\b]", "The Department");
cleanInst.replaceAll("[\bThe Dept.\b]", "The Department");
cleanInst.replaceAll("[\bthe dept.\b]", "The Department");
cleanInst.replaceAll("[\bThe Dept\b]", "The Department");
cleanInst.replaceAll("[\bthe dept\b]", "The Department");
cleanInst.replaceAll("[\bDept.\b]", "The Department");
cleanInst.replaceAll("[\bdept.\b]", "The Department");
cleanInst.replaceAll("[\bdept\b]", "The Department");
Run Code Online (Sandbox Code Playgroud)
实现上述替换的最简单方法是什么?
我需要读取配置文件我在运行以下代码时遇到此错误:
java.util.Properties$LineReader.readLine
文件config.cfg存在并具有r/w权限.
import java.util.*;
import java.util.Properties;
public class Config
{
Properties configFile;
public Config()
{
configFile = new java.util.Properties();
try {
configFile.load(this.getClass().getClassLoader().
getResourceAsStream("config.cfg"));
}catch(Exception eta){
eta.printStackTrace();
}
}
public String getProperty(String key)
{
String value = this.configFile.getProperty(key);
return value;
}
}
Run Code Online (Sandbox Code Playgroud)
[java] java.lang.NullPointerException
[java] at java.util.Properties$LineReader.readLine(Properties.java:418)
[java] at java.util.Properties.load0(Properties.java:337)
[java] at java.util.Properties.load(Properties.java:325)
[java] at Config.<init>(Unknown Source)
[java] at ClosureBuilder.<clinit>(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
SRC
- > config.java
- > config.cfg
我正在考虑使用BigDecimal比较两个四舍五入到两位数的货币值.例如,我希望以下产生0,因为我正在比较应该舍入到0.02的东西和0.02.但它产生-1 !! 有没有正确的方法来做到这一点?
这也适用于较大的数字,如123.45 vs 123.4534 ...当使用"compareTo"时应该产生0.
我尝试过使用数学上下文,但它看起来并不优雅......有正确的方法吗?
BigDecimal spread = new BigDecimal(0.01934);
spread.setScale(2, RoundingMode.HALF_EVEN);
System.out.format("0.0193 ? 0.02 = %d\n", spread.compareTo(new BigDecimal(0.02)));
Run Code Online (Sandbox Code Playgroud)
解决方案是:
BigDecimal spread = new BigDecimal(0.01934).setScale(2, RoundingMode.HALF_EVEN);
BigDecimal loSpread = new BigDecimal(0.02).setScale(2, RoundingMode.HALF_EVEN);
System.out.format("0.0193 ? 0.02 = %d\n", spread.compareTo(loSpread));
Run Code Online (Sandbox Code Playgroud) 我有一个简单的问题,但我找不到Java EE 6的答案!
有状态会话bean是否应该实现Serializable?
我测试了有没有实现java.io.Serializable,没有不同的错误.
我的感觉告诉我,有状态会话bean必须实现Serializable,因为它可以在长期会话中持久化......
我有许多DTO对象。每个dto类都有方法
convertDTO(Entity entity)convertDTOList(List<Entity> entity) 我想为我的dto对象转换器使用设计模式。我可以使用哪种设计模式,如何使用?
推土机框架很好。但是我想写一个通用的模式。
我正在尝试使用在Java 6中添加的newFactory()方法XMLOutputFactory.但是Eclipse保持标记newFactory()为类型的未定义XMLOutputFactory.JRE7是安装的唯一运行时,位于新Java项目的构建路径中.该项目本身只有JRE7(JRE系统库)和Ivy设置.我一直得到的错误是
The method newFactory() is undefined for the type XMLOutputFactory
Run Code Online (Sandbox Code Playgroud)
任何想法如何让Eclipse接受newFactory?几乎只是return XMLOutputFactory.newFactory()用作调用函数的唯一地方.
如何创建一个简单的 jaxb Java 类来表示以下 xml
<rootelem>
<myelem name="abc" myatt="true"/>
<myelem name="def">
<Key value="newvalue"/>
</myelem>
<myelem name="xyz">
<Key value="42"/>
</myelem>
</rootelem>
Run Code Online (Sandbox Code Playgroud)
可以有多个myelem,每个myelem可以包含多个key
我不想使用 xsd
我有一个JSP文件,其中包含如下链接:
<a href="links.do?method=homeAdmin">
<a href="links.do?method=signUp">
Run Code Online (Sandbox Code Playgroud)
我有一个动作类LinkAction.java:
public class LinkAction extends org.apache.struts.action.Action {
public ActionForward signUp(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("signUp");
}
public ActionForward homeAdmin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("homeAdmin");
}
}
Run Code Online (Sandbox Code Playgroud)
问题是它不起作用.但是当我把它改成这样的东西时,它只适用于signUp动作.
public class LinkAction extends org.apache.struts.action.Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("signUp");
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过把它改成
public class LinkAction extends DispatchAction …Run Code Online (Sandbox Code Playgroud) java ×10
bigdecimal ×1
client ×1
dao ×1
dto ×1
html ×1
java-ee-6 ×1
jax-ws ×1
jaxb ×1
jdbc ×1
jsp ×1
netbeans ×1
properties ×1
regex ×1
replaceall ×1
stax ×1
string ×1
struts-1 ×1
web-services ×1