2016-09-13 15 views
0

クライアントが例外を処理してユーザーに適切な情報を与えることができるように、認証プロセス中にいくつかのビジネス例外がスローされるJAX-WS WebServiceを作成しました。JAX-WSクライアントが間違ったジェネリックWebService例外を受け取った

WSは4か月前に使用され始めましたが、その時点までにすべてうまくいっていましたが、その後私たちのクライアントは多くの新機能を要求しており、契約者はここのほとんどすべての開発者に変わりました。何が間違っているか。

お願いします。

@WebService 
@ApplicationScoped 
public class MyWS { 

    @WebMethod 
    public MyVO doSomething(parameters...) throws UserAuthenticationException { 
     throw new UserAuthenticationException(
      "The message the business guys asked to send..." 
     ); 
    } 

今Exceptionクラス:

public class UserAuthenticationException extends Exception { 

    private String details; 

    /** 
    * 
    */ 
    private static final long serialVersionUID = -3173043626093972452L; 

    public UserAuthenticationException(String msg, Throwable t) { 
     super(msg, t); 
    } 

    public UserAuthenticationException(String reason, String details) { 
     super(reason); 
     this.details = details; 
    } 

    public UserAuthenticationException(String msg) { 
     super(msg); 
     this.details = msg; 
    } 

    public String getFaultInfo() { 
     return this.details; 
    } 
} 

私の例外はここで障害

<portType name="MyWS"><operation name="doSomething"><input message="tns:doSomething" wsam:Action="http://ws.../MyWS/doSomethingRequest"> 
... 
    </output><fault name="UserAuthenticationException" message="tns:UserAuthenticationException" wsam:Action="http://ws.../MyWS/doSomething/Fault/UserAuthenticationException"> 
    </fault></operation> 

にマップされたWSDLに表示することが可能であるが、クライアント側のメソッド呼び出しでありますそれは常にcatch(WebServiceException e)ブロックに入ります。

**すべてのスタブ/アーティファクトはcr WSImportによって食べられた。

public void callMyWs() { 
    try { 
     //we use a proxy 
     MyWS myWsPort = MyWS.getMyWSPort(); 
     myWsPort.doSomething() 

    } catch (UserAuthenticationException_Exception e) { 
     JOptionPane.showMessageDialog(e.getMessage()); 
     ->>>> //Here is where I expect it shoud go... 

    } catch (MalformedURLException e) { 
     ... 
    } catch (WebServiceException e) { 
     ... 
     //here is where it goes 
    } catch (Exception e) { 
     .... 
    } 
} 

最後に、私のWS方法

@WebService(name = "MyWS", targetNamespace = "...") 
@XmlSeeAlso({ 
    ObjectFactory.class 
}) 
public interface MyWS { 


    /** 
    * 
    * @return 
    *  returns MyVO 
    * @throws UserAuthenticationException_Exception 
    */ 
    @WebMethod 
    @WebResult(targetNamespace = "") 
    @RequestWrapper(...", className = "...") 
    @ResponseWrapper(localName = "...", targetNamespace = "...", className = "...") 
    @Action(input = "...", output = "...", fault = { 
     @FaultAction(className = UserAuthenticationException_Exception.class, value = "ws.../MyWS/doSomething/Fault/UserAuthenticationException") 
    }) 
    public MyVO doSomething(params...) 
     throws UserAuthenticationException_Exception 
    ; 

でwsimportのによって作成されたインタフェースは、私はちょうど

間違っているものを見ることができない--- EDITED ----

スタックトレース

javax.xml.ws.ProtocolException: The message the business guys asked to send... 
    at org.apache.axis2.jaxws.ExceptionFactory.createProtocolException(ExceptionFactory.java:199) 
    at org.apache.axis2.jaxws.ExceptionFactory.makeProtocolException(ExceptionFactory.java:97) 
    at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1370) 
    at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:1089) 
    at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalFaultResponse(DocLitWrappedMethodMarshaller.java:680) 
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:626) 
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:566) 
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:432) 
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:213) 
    at com.sun.proxy.$Proxy29.callMyService(Unknown Source) 
    at package(Main.java:154) 
    at package.Main$1.actionPerformed(Main.java:84) 
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) 
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) 
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
    at java.awt.Component.processMouseEvent(Component.java:6525) 
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) 
    at java.awt.Component.processEvent(Component.java:6290) 
    at java.awt.Container.processEvent(Container.java:2234) 
    at java.awt.Component.dispatchEventImpl(Component.java:4881) 
    at java.awt.Container.dispatchEventImpl(Container.java:2292) 
    at java.awt.Component.dispatchEvent(Component.java:4703) 
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898) 
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533) 
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462) 
    at java.awt.Container.dispatchEventImpl(Container.java:2278) 
    at java.awt.Window.dispatchEventImpl(Window.java:2750) 
    at java.awt.Component.dispatchEvent(Component.java:4703) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) 
    at java.awt.EventQueue.access$500(EventQueue.java:97) 
    at java.awt.EventQueue$3.run(EventQueue.java:709) 
    at java.awt.EventQueue$3.run(EventQueue.java:703) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) 
    at java.awt.EventQueue$4.run(EventQueue.java:731) 
    at java.awt.EventQueue$4.run(EventQueue.java:729) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 
+0

例外のスタックトレースを投稿できますか? UserAuthenticationException障害に関連していない可能性がありますが、他のエラーによって引き起こされた可能性があります。輸送レベルで? – MGorgon

+0

私の悪い!私はあなたの注意のために、スタックトレースを投稿しました。 – Scrougge

+0

クライアントの軸のバージョンは何ですか?サーバーが有効なフォルトメッセージを返すことをSoapUIで確認できましたか? – MGorgon

答えて

0

最後に、私はそれを再び働かせました。

I noticed some examples use a QName object to get service instance before creating the proxy, so I give it a try and it worked! 

MyWSService service = new MyWSService(new URL(urlWSDL), new QName("http://ws..../", "MyWSService ")); 
関連する問題