i am call web service with axis2 plugin .The methodology used is rpc.
the code main is :
GetPayIDBillIDStub stub = new GetPayIDBillIDStub("http://80.91.4.113:8088/services/GetPayIDBillID_Proxy");
stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
GetPayIDBillIDStub.PaymentInput input = new GetPayIDBillIDStub.PaymentInput();
input.setPassword("123456");
input.setTelephone(2111111111);
input.setUsername("test");
paymentTelOPR.setPaymentTelOPRRequest(input);
org.apache.axiom.om.OMFactory factory = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
paymentTelOPRResponseE = stub.paymentTelOPR(paymentTelOPRE.setPaymentTelOPRRequest(paymentTelOPR.getOMElement(GetPayIDBillIDStub.PaymentTelOPR.MY_QNAME, factory)));
error is :
Exception in thread "main" java.lang.IllegalArgumentException: The MessageContext does not have an associated SOAPFault.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:556)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at mypackage.GetPayIDBillIDStub.paymentTelOPR(GetPayIDBillIDStub.java:182)
at Run.main(Run.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
help for me.
We recently had this Problem because the response contained no SOAPFault (in fact was the expected answer to the service call) but the http status code of the response was 5xx (500 in our case).
Maybe something similar in your case.
You can verify this by using an generic Webservice client like SoapUI which can also display the raw hhtp response.
I know it is a late answer, but I can help the new engineers with my experience.
I got the same error where I was using SOAP UI with my API. The problem started when I replaced my mocked response by a fault response just for testing it. But once I retried to use the correct code, it didn't work and it gave me this error.
The solution was: that I have to delete the response because it is considered as a fault response and missing the fault code, When I created a new response and deleted the old one, it worked without getting this exception
Related
I have been trying to create a new API in WSO2 using WSO2 REST services, While I am able to register DCR application, get authtoken and list down already existing APIs, the create new API call fails with 500 Error.
The same error I receive when trying to crate new API from WSO2 UI. Been using minimal required fields as well as tried with full API body given in documentation.
Here is the API Call:
Endpoint: **https://serverIP:9443/api/am/publisher/v1.2/apis**
Type : POST
Auth: Access-token
Body: {
"name": "Rest Test API",
"context": "/test",
"version": "1.0.0"
}
Postman Response: {
"code": 500,
"message": "Internal server error",
"description": "The server encountered an internal error. Please contact administrator.",
"moreInfo": "",
"error": []
}
Tried checking the logs but they all point to no specific details except the null pointer exception.
Logs for reference: https-jsse-nio-9443-exec-19] ERROR GlobalThrowableMapper An unknown exception has been captured by the
global exception mapper. java.lang.NullPointerException: null
at org.wso2.carbon.apimgt.impl.APIProviderImpl.validateSharedScopes_aroundBody486(APIProviderImpl.java:8708)
~[org.wso2.carbon.apimgt.impl_6.7.206.jar:?]
at org.wso2.carbon.apimgt.impl.APIProviderImpl.validateSharedScopes(APIProviderImpl.java:8706)
~[org.wso2.carbon.apimgt.impl_6.7.206.jar:?]
at org.wso2.carbon.apimgt.impl.UserAwareAPIProvider.validateSharedScopes(UserAwareAPIProvider.java:1)
~[org.wso2.carbon.apimgt.impl_6.7.206.jar:?]
at org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl.validateScopes(ApisApiServiceImpl.java:4510) ~[classes/:?]
at org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl.apisPost(ApisApiServiceImpl.java:278)
~[classes/:?]
at org.wso2.carbon.apimgt.rest.api.publisher.v1.ApisApi.apisPost(ApisApi.java:962)
~[classes/:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179)
~[cxf-core-3.2.8.jar:3.2.8]
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
~[cxf-core-3.2.8.jar:3.2.8]
What could be the problem? Is there a specific location I can see for specific logs?
TIA
According to the log, It seems like the payload you passed is invalid or missing mandatory fields.
Seems like, You have try to add a shared scope to an API which is not already defined. So please proceed and check the payload provided is correct.
There are 2 points you need to consider in this case. They are as follows.
1. Rest API version
Based on your API endpoint "https://serverIP:9443/api/am/publisher/v1.2/apis" you are using the REST API version v1.2. Currently, WSO2 APIM does not support such a version. The latest wso2am-3.2.0 uses v1 version. If you are using wso2am-2.2.0 then the version should be v0.12. Please check this.
2. Scopes
In order to add new APIs via a REST API call, you should have generated the access tokens with the following OAuth 2.0 scope in order to access those resources. Please check if you have generated the access tokens with the relevant scopes.
wso2am-3.2.0: apim:api_create (link)
wso2am-2.2.0: apim:api_create (link)
I'm implementing a SOAP web service using Spring WS.
Most of my implementation is done using types with #Endpoint annotations and methods in these types with #SoapAction annotations. Some endpoint interceptors also help glue things together.
I'm using Spring exception handling with SoapFaultAnnotationExceptionResolver that enriches the SoapFault with some specific details.
This works very well. But I have a customer requirement that says that I also have to provide customized SoapFaults for those cases where the service is invoked with an invalid soap-action. Meaning, a soap action for which I have no matching #SoapAction annotation.
What happens now is that Spring logs this:
[WARN] org.springframework.ws.server.EndpointNotFound No endpoint mapping found for [AxiomSoapMessage {http://www.example.com/myservice/xml.schema/2010/06/01}MyRequest]
I get this returned along with a 404 return code from the Jetty server that hosts this web service.
How can I catch these exceptions and add some custom soapfault handling in this situation? It seems like if only org.springframework.ws.NoEndpointFoundException had a #SoapFault annotation, I could have it go through my exception resolver and customize it that way. But it doesn't, unfortunately.
I think I may have to implement some custom "catch-all" endpoint mapping but I'm just not sure how to do this, and how to ensure that mapping to the specific endpoints are attempted first.
Anyone have a suggestion for how to do this?
The exception seems to be thrown from the class MessageDispatcher in the method dispatch:
mappedEndpoint = getEndpoint(messageContext);
if (mappedEndpoint == null || mappedEndpoint.getEndpoint() == null) {
throw new NoEndpointFoundException(messageContext.getRequest());
I suggest to extends this class and instead of throwing an exception, you could add a soap fault as such:
SoapMessage response = (SoapMessage) messageContext.getResponse();
String faultString = "any message"
SoapBody body = response.getSoapBody();
SoapFault fault = body.addServerOrReceiverFault(faultString, getLocale());
You can take a look SimpleSoapExceptionResolver that deals with exceptions on the endpoints.
I'm looking for some way to respond to a SOAP request with a soap fault.
Right now I can only create a fault when an exception is thrown via an AbstractEndpointExceptionResolver.
I have looked at an EndpointInterceptorAdapter but I'm not sure how to inspect or modify the response. For instance if an endpoint returns a ValidResponse but there were no values found or returned in a list in the response I would like to respond to the users request with a SoapFault instead.
We make efforts to follow "Don't Use Exceptions For Flow Control" but I've been un-successful with creating a SoapFault from an interceptor or from the endpoint without throwing an exception.
Well, I think AbstractValidatingInterceptor comes to the rescue. At least from source code part: how to handle response from interceptor and how to deal with WebServiceMessage response.
Bear in mind, the WebServiceMessage can be cast to the SoapMessage and you can populate your custom SoapFault using its SoapBody:
SoapBody soapBody = ((SoapMessage) messageContext.getResponse()).getSoapBody();
I needed some help fixing this issue that i am facing currently with WS class. When i execute the client i get this exception. I googled for a solution, but done seem to find anything that would help.
The exception that i see is this:
Exception in thread "main" javax.xml.ws.WebServiceException: The following WSDL exception occurred: WSDLException: faultCode=WSDL4JWrapper : : javax.wsdl.WSDLException: WSDLException: faultCode=WSDL4JWrapper : : java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:9090/TimeServiceWS/services/TimeServerImplService
at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:173)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
at org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.setupWsdlDefinition(ServiceDescriptionImpl.java:1202)
at org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.<init>(ServiceDescriptionImpl.java:249)
at org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.<init>(ServiceDescriptionImpl.java:172)
at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:134)
at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:79)
at org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescription(DescriptionFactory.java:78)
at org.apache.axis2.jaxws.spi.ServiceDelegate.<init>(ServiceDelegate.java:218)
at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:83)
at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:79)
at javax.xml.ws.Service.<init>(Service.java:77)
at javax.xml.ws.Service.create(Service.java:707)
at ch01.ts.TimeServerConsumer.main(TimeServerConsumer.java:47)
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=WSDL4JWrapper : : javax.wsdl.WSDLException: WSDLException: faultCode=WSDL4JWrapper : : java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:9090/TimeServiceWS/services/TimeServerImplService
at org.apache.axis2.jaxws.util.WSDL4JWrapper.commonPartsURLConstructor(WSDL4JWrapper.java:234)
at org.apache.axis2.jaxws.util.WSDL4JWrapper.<init>(WSDL4JWrapper.java:156)
at org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.setupWsdlDefinition(ServiceDescriptionImpl.java:1182)
... 11 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=WSDL4JWrapper : : java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:9090/TimeServiceWS/services/TimeServerImplService
at org.apache.axis2.jaxws.util.WSDL4JWrapper.commonPartsURLConstructor(WSDL4JWrapper.java:203)
... 13 more
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:9090/TimeServiceWS/services/TimeServerImplService
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
at org.apache.axis2.jaxws.util.WSDL4JWrapper$14.run(WSDL4JWrapper.java:974)
at org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:132)
at org.apache.axis2.jaxws.util.WSDL4JWrapper.getInputStream(WSDL4JWrapper.java:971)
at org.apache.axis2.jaxws.util.WSDL4JWrapper.commonPartsURLConstructor(WSDL4JWrapper.java:189)
... 13 more
I have deployed my WS in Tomcat. If you need the code and the WSDL, let me know, I would provide it. I asked this on some other forums as well without any help. So some help would be appreciated.
This one in particular looks like your path
http://localhost:9090/TimeServiceWS/services/TimeServerImplService
is having some sort of internal error. I would look at your logs but without any other code it is impossible to tell.
I'm trying out an Jax-RS example that involves EJB+JPA+JSF. i can normally run the example but when i remove the comments below in Stateless EJB bean;
// #Context
// private UriInfo uriInfo;
/* #POST
#Path("book")
#Consumes(MediaType.APPLICATION_JSON)
public Response createJaxbBook(JAXBElement<Book> bookJaxb) {
Book book = bookJaxb.getValue();
book.setIsbn(numberGenerator.generateNumber());
em.persist(book);
em.flush(); // to get the id
URI bookUri = uriInfo.getAbsolutePathBuilder().path(book.getId().toString()).build();
Response resp = Response.created(bookUri).build();
logger.fine("ItemEJB.createJaxbBook():" + resp.toString());
return resp;
} */
when i run the example with uncommented version, i get error so that ;
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: An error occurred performing resource injection on managed bean itemController
root cause
com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean itemController
root cause
com.sun.faces.spi.InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting invoke lifecycle method private void org.beginningee6.training.web.ItemController.initList()
root cause
com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting invoke lifecycle method private void org.beginningee6.training.web.ItemController.initList()
root cause
java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException
root cause
java.lang.reflect.InvocationTargetException
root cause
javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
root cause
javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
root cause
javax.ejb.CreateException: Could not create stateless EJB
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
GlassFish Server Open Source Edition 3.1.1
When i insert a record to database with curl ;
curl -X POST --data-binary "{ \"title\":\"book333\", \"price\":\"24.0\", \"description\":\"3rd Scifi IT book\", \"illustrations\":\"false\", \"isbn\":\"134-234\", \"nbOfPage\":\"241\" }" -H "Content-Type: application/json" -H "Accept: application/json" http://localhost:8080/Lab17-REST/rs/items/book
then refresh the page, project is normally running. How can i candle this issue.