2016-08-29 21 views
0

私はOSGIを使用してWebサービスを作成しました。私のアプリケーションサーバーはGlassfish 3です。Java 1.7@RebestScopedを@WebServiceに追加するとエラー404が発生する

@WebService(name="MyService", serviceName = "MyWebServices") 
public interface IMyService 
{ 
//some code 
} 

@Stateless(name = "MyService") 
@HandlerChain(file = "handler-chain.xml") 
@WebService(serviceName = "MyWebServices", endpointInterface="com.examlple.webservices.IMyService") 
public class MyService implements IMyService 
{ 
//some code 
} 

私のサービスが動作します!そしてサーブレットフィルタを追加したいと思います。私はthis topicの答えで、@RequestScopedアノテーションをサービスの実装に追加すべきだと気づいた。

しかしその後、私は応答で404エラーが発生しました。私はこのバグの理由を見つけることができません。

+0

あなたは@PostConstructをしようとすることはできませんまたは@Interceptor(..)私が述べたannonationsスレッド? – lsiva

答えて

0

サーブレットを持っていないので、ここでServletFilterは間違ったツールだと思います。あなたが必要とするものはSoapHandlerです。ここで

は、それがどのように見えることができるかの例です:

import java.io.IOException; 
import java.util.Set; 

import javax.xml.namespace.QName; 
import javax.xml.soap.SOAPException; 
import javax.xml.soap.SOAPMessage; 
import javax.xml.ws.handler.MessageContext; 
import javax.xml.ws.handler.soap.SOAPHandler; 
import javax.xml.ws.handler.soap.SOAPMessageContext; 

public class MyServiceLogHandler implements SOAPHandler<SOAPMessageContext> { 

    @Override 
    public Set<QName> getHeaders() { 
     // TODO Auto-generated method stub 
     return null; 
    } 

    @Override 
    public void close(MessageContext arg0) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public boolean handleFault(SOAPMessageContext arg0) { 
     SOAPMessage message= arg0.getMessage(); 
     try { 
      message.writeTo(System.out); 
     } catch (SOAPException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     return false; 
    } 

    @Override 
    public boolean handleMessage(SOAPMessageContext arg0) { 
     SOAPMessage message= arg0.getMessage(); 
     boolean isOutboundMessage= (Boolean)arg0.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY); 
     if(isOutboundMessage){ 
      System.out.println("OUTBOUND MESSAGE\n"); 

     }else{ 
      System.out.println("INBOUND MESSAGE\n"); 
     } 
     try { 
      message.writeTo(System.out); 
     } catch (SOAPException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     return false; 
    } 
} 

も参照してください:

+0

SOAPHandlerを使用して 'http:// localhost/MyWebServices/MyService?WSDL'のようなリクエストをインターラプトできますか? – Paul

+0

申し訳ありませんが、私は "切片"を意味します – Paul

+0

私はそれを試していないが、私はそれが動作するはずだと思います。 – unwichtich

関連する問題