关于使用 Apache CXF 的 java:JAXWS Webservice – 名称”对于 JDOM/XML 命名空间是不合法的:命名空间 URI 必须是非空且非空的字符串

JAXWS Webservice using Apache CXF - The name "" is not legal for JDOM/XML namespaces: Namespace URIs must be non-null and non-empty Strings

我正在使用带有注释的 Code First 方法使用 Apache CXF (2.7.14) 开发 JAXWS Webservice。我已经使用 JAXWS 注释对 SEI、SEI 实现类和具有 JAXB 注释的域对象进行了注释。每当尝试使用 Eclipse 生成 WSDL 时,我都会遇到以下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
IWAB0014E Unexpected exception occurred.
  The name"" is not legal for JDOM/XML namespaces: Namespace URIs must be non-null and non-empty Strings.
      org.jdom.IllegalNameException: The name"" is not legal for JDOM/XML namespaces: Namespace URIs must be non-null and non-empty Strings.
      at org.jdom.Namespace.getNamespace(Namespace.java:162)
      at org.eclipse.jst.ws.internal.cxf.core.utils.SpringUtils.createJAXWSEndpoint(SpringUtils.java:414)
      at org.eclipse.jst.ws.internal.cxf.creation.core.commands.Java2WSCommand.execute(Java2WSCommand.java:103)
      at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.runCommand(CommandFragmentEngine.java:419)
      at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.visitTop(CommandFragmentEngine.java:359)
      at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.moveForwardToNextStop(CommandFragmentEngine.java:212)
      at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager$6.run(SimpleCommandEngineManager.java:294)
      at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:466)
      at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:374)
      at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1059)
      at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager.runForwardToNextStop(SimpleCommandEngineManager.java:264)
      at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.runForwardToNextStop(WizardPageManager.java:91)
      at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.getNextPage(WizardPageManager.java:154)
      at org.eclipse.wst.command.internal.env.ui.widgets.SimpleWizardPage.getNextPage(SimpleWizardPage.java:136)
      at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:935)
      at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:434)
      at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:619)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
      at org.eclipse.jface.window.Window.runEventLoop(Window.java:832)
      at org.eclipse.jface.window.Window.open(Window.java:808)
      at org.eclipse.wst.command.internal.env.ui.widgets.popup.DynamicPopupWizard.run(DynamicPopupWizard.java:130)
      at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
      at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
      at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
      at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
      at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
      at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
      at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
      at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

员工服务等级是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@WebService
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL, parameterStyle = ParameterStyle.WRAPPED)
@WebFault(name ="exception", faultBean ="java.lang.Exception")
public interface EmployeeService
{
    @WebMethod(exclude = false)
    @RequestWrapper(className ="home.cxfwebservicesdemo.employeeservice.domain.Employee")
    @Oneway
    public void addEmployee(@WebParam(name ="employee", mode = Mode.IN) Employee employee) throws Exception;

    @WebMethod(exclude = false)
    @RequestWrapper(className ="home.cxfwebservicesdemo.employeeservice.domain.Employee")
    @Oneway
    public void updateEmployee(@WebParam(name ="employee", mode = Mode.IN) Employee employee) throws Exception;

    @WebMethod(exclude = false)
    @Oneway
    public void deleteEmployee(@WebParam(name ="employeeId", mode = Mode.IN) long employeeId) throws Exception;

    @WebMethod(exclude = false)
    @ResponseWrapper(className ="home.cxfwebservicesdemo.employeeservice.domain.Employee")
    @WebResult(name ="employee")
    public Employee getEmployeeById(@WebParam(name ="employeeId", mode = Mode.IN) long employeeId) throws Exception;

    /*
     * @WebMethod(exclude = false)
     * @ResponseWrapper(className ="java.util.ArrayList")
     * @WebResult(name ="employeeList") public List<Employee> getAllEmployees() throws Exception;
     */

}

我没有广泛地从事网络服务工作。

如果您需要更多详细信息,请告诉我。

有人可以帮我找到解决上述问题的方法吗?

谢谢!


在使用 CXF Web 服务时,我在使用向导生成 Web 服务时遇到了类似的错误。为了解决这个问题,我将命名空间属性值添加到 @WebService 注释

1
2
3
4
5
@WebService(targetNamespace="http://www.benjmaz.com")
public class MyWebService{
   @Resource
   private WebServiceContext context;
}

提供您选择的其他名称(尤其是您公司的域名)作为目标名称空间