[JBoss Web Services Users] - custom fault mapping with jax-rpcâ
by newmanw10
Sorry posted this in the CXF forum, this is probably a better place. Not sure how to remove the CXF post on this subject.
I am currently working on an old legacy system that is using jax-rpc. I would like to add in some custom faults such that I can inform clients better. I.E. I can throw custom exceptions/faults such that the user can catch them to determine the best course of action. However using JBoss I have not been able to get this to work. The main problem is that in the SOAP message that comes back there is no tag. This tag is how the exception would get deserialized on the client, so without that tag the client will have no idea what exception/fault was thrown.
Has anyone every gotten a custom fault to work with JBoss? My guess is no as I have not been able to find out anything on this problem.
I am running 4.2.3.GA and out of the box is has jbossws-native-3.0.1, I also installed jbossws-native-3.1.1.GA to see if it fixed the problem but I was still out of luck. Please help I am all out of ideas! Below are some code snippets to show what I am talking about. If you need more please let me know.
I took a simple example jax-rpc HelloWord service from the java tutorial section and added a fault to the wsdl.
Here is a snippet:
| <portType name="HelloIF">
| <operation name="sayHello" parameterOrder="String_1">
| <input message="tns:HelloIF_sayHello"/>
| <output message="tns:HelloIF_sayHelloResponse"/>
| <fault name="fault" message="tns:sayHelloException"></fault>
| </operation>
| </portType>
|
I generated the jax-rpc classes:
Here is the fault/exception generated:
| public class SayHelloException extends java.lang.Exception {
| private java.lang.String message;
|
|
| public SayHelloException(java.lang.String message) {
| super(message);
| this.message = message;
| }
|
| public java.lang.String getMessage() {
| return message;
| }
| }
|
Here is the endpoint interface:
| public interface HelloIF extends java.rmi.Remote {
| public java.lang.String sayHello(boolean string_1) throws
| samples.webservices.jaxrpc.simple.SayHelloException, java.rmi.RemoteException;
| }
|
I also creating the jax-rpc mapping file and deployed with the war in the web-inf directory as well as my webservices.xml and web.xml.
At this point I am not sure why jboss is not creating the tag in the SOAP message that gets sent back to the server.
Here is how I throw the custom exception on the server:
| throw new SayHelloException("Throwing custom exception/fault from WS");
|
Here is my client:
| try {
| Stub stub = (Stub) port;
| stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/hello/simple");
| String result = port.sayHello(true);
| System.out.println(result);
| } catch (SayHelloException ex) {
| System.out.println("PASS! caught a custom exception");
| } catch (RemoteException ex) {
| } catch (Exception ex) {
| System.out.println("FAIL! caught a Exception");
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263201#4263201
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263201
14 years, 11 months
[JBoss Web Services Users] - Server was unable to process request. ---> Object reference
by fagnermoura
im using jboss 4.2.3 with Native stack for jbossws.
calling the web service, im receiving this exception:
javax.xml.ws.soap.SOAPFaultException: Server was unable to process request. ---> Object reference not set to an instance of an object.
##############
Method being called
##############
@WebMethod(operationName = "InsertOrder", action = "http://tempuri.org/InsertOrder")
@WebResult(name = "InsertOrderResult", targetNamespace = "http://tempuri.org/")
@RequestWrapper(localName = "InsertOrder", targetNamespace = "http://tempuri.org/", className = "org.tempuri.InsertOrder")
@ResponseWrapper(localName = "InsertOrderResponse", targetNamespace = "http://tempuri.org/", className = "org.tempuri.InsertOrderResponse")
public RETPEDIDO insertOrder(@WebParam(name = "_pedido", targetNamespace = "http://tempuri.org/") PedidoItens pedido);
Other services works fine, but this method that return complexType not.
I just try with soap 1.1 and soap 1.2, but dont work.
Through my swing client, i can to call it. (i include the client dir, from jboss, in the classpath)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263194#4263194
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263194
14 years, 11 months
custom fault mapping with jax-rpc
by Billy Newman
I am currently working on an old legacy system that is using jax-rpc. I would like to add in some custom faults such that I can inform clients better. I.E. I can throw custom exceptions/faults such that the user can catch them to determine the best course of action. However using JBoss I have not been able to get this to work. The main problem is that in the SOAP message that comes back there is no <detail> tag. This tag is how the exception would get deserialized on the client, so without that tag the client will have no idea what exception/fault was thrown.
Has anyone every gotten a custom fault to work with JBoss? My guess is no as I have not been able to find out anything on this problem.
I am running 4.2.3.GA and out of the box is has jbossws-native-3.0.1, I also installed jbossws-native-3.1.1.GA to see if it fixed the problem but I was still out of luck. Please help I am all out of ideas! Below are some code snippets to show what I am talking about. If you need more please let me know.
I took a simple example jax-rpc HelloWord service from the java tutorial section and added a fault to the wsdl.
Here is a snippet:
<portType name="HelloIF">
<operation name="sayHello" parameterOrder="String_1">
<input message="tns:HelloIF_sayHello"/>
<output message="tns:HelloIF_sayHelloResponse"/>
<fault name="fault" message="tns:sayHelloException"></fault>
</operation>
</portType>
I generated the jax-rpc classes:
Here is the fault/exception generated:
public class SayHelloException extends java.lang.Exception {
private java.lang.String message;
public SayHelloException(java.lang.String message) {
super(message);
this.message = message;
}
public java.lang.String getMessage() {
return message;
}
}
Here is the endpoint interface:
public interface HelloIF extends java.rmi.Remote {
public java.lang.String sayHello(boolean string_1) throws
samples.webservices.jaxrpc.simple.SayHelloException, java.rmi.RemoteException;
}
I also creating the jax-rpc mapping file and deployed with the war in the web-inf directory as well as my webservices.xml and web.xml.
At this point I am not sure why jboss is not creating the <detail> tag in the SOAP message that gets sent back to the server.
Here is how I throw the custom exception on the server:
throw new SayHelloException("Throwing custom exception/fault from WS");
Here is my client:
try {
Stub stub = (Stub) port;
stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/hello/simple");
String result = port.sayHello(true);
System.out.println(result);
} catch (SayHelloException ex) {
System.out.println("PASS! caught a custom exception");
} catch (RemoteException ex) {
} catch (Exception ex) {
System.out.println("FAIL! caught a Exception");
}
_________________________________________________________________
Windows 7: It works the way you want. Learn more.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::T:...
14 years, 11 months
[JBoss Web Services Users] - WSDL generated incorrectly?
by Elenthril
Hi,
I am using wstools from eclipse 3.5.1. and jboss-5.1.0.GA to generate a top-down webservice. It is generated from the following, I believe (syntacticly) correct, wsdl with <mime:multipartRelated> elements.
| <?xml version="1.0" encoding="UTF-8"?>
| <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
| xmlns:tns="http://com.lei.nl/modelAgent"
| xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
| xmlns:xsd="http://www.w3.org/2001/XMLSchema"
| xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
| xmlns:lei="http://com.lei.nl/modelAgent"
| name="ModelAgentService"
| targetNamespace="http://com.lei.nl/modelAgent">
| <wsdl:types>
| <xsd:schema xmlns:lei="http://com.lei.nl/modelAgent" targetNamespace="http://com.lei.nl/modelAgent" >
| <xsd:element name="ModelAgentRequest">
| <xsd:complexType>
| <xsd:sequence>
| <xsd:element minOccurs="1" maxOccurs="1" name="modelType" type="xsd:string"/>
| <xsd:element minOccurs="1" maxOccurs="1" name="modelName" type="xsd:string"/>
| <xsd:element minOccurs="0" maxOccurs="unbounded" name="modelParameters" type="lei:ModelParameter"/>
| </xsd:sequence>
| </xsd:complexType>
| </xsd:element>
| <xsd:element name="ModelAgentResponse">
| <xsd:complexType>
| <xsd:sequence>
| <xsd:element minOccurs="1" maxOccurs="1" name="returnCode" type="xsd:string"/>
| </xsd:sequence>
| </xsd:complexType>
| </xsd:element>
| <xsd:complexType name="ModelParameter">
| <xsd:sequence>
| <xsd:element minOccurs="1" name="parameterName" type="xsd:string"/>
| <xsd:element minOccurs="1" name="parameterValue" type="xsd:string"/>
| </xsd:sequence>
| </xsd:complexType>
| </xsd:schema>
| </wsdl:types>
| <wsdl:message name="invokeRequestMsg">
| <wsdl:part name="ModelAgentRequest" element="lei:ModelAgentRequest"/>
| <wsdl:part name="gdxAttachment" type="xsd:base64Binary"/>
| </wsdl:message>
| <wsdl:message name="invokeResponseMsg">
| <wsdl:part name="ModelAgentResponse" element="lei:ModelAgentResponse"/>
| <wsdl:part name="gdxAttachment" type="xsd:base64Binary"/>
| </wsdl:message>
| <wsdl:portType name="ModelAgentService">
| <wsdl:operation name="invoke">
| <wsdl:input message="tns:invokeRequestMsg" name="invokeRequestMsg"/>
| <wsdl:output message="tns:invokeResponseMsg" name="invokeResponseMsg"/>
| </wsdl:operation>
| </wsdl:portType>
| <wsdl:binding name="ModelAgentServiceSOAP" type="tns:ModelAgentService">
| <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
| <wsdl:operation name="invoke">
| <soap:operation soapAction=""/>
| <wsdl:input name="invokeRequestMsg">
| <mime:multipartRelated>
| <mime:part>
| <soap:body parts="ModelAgentRequest" use="literal"/>
| </mime:part>
| <mime:part>
| <mime:content part="gdxAttachment" type="application/octet-stream"/>
| </mime:part>
| </mime:multipartRelated>
| </wsdl:input>
| <wsdl:output name="invokeResponseMsg">
| <mime:multipartRelated>
| <mime:part>
| <soap:body parts="ModelAgentResponse" use="literal"/>
| </mime:part>
| <mime:part>
| <mime:content part="gdxAttachment" type="application/octet-stream"/>
| </mime:part>
| </mime:multipartRelated>
| </wsdl:output>
| </wsdl:operation>
| </wsdl:binding>
| <wsdl:service name="ModelAgentSOAPService">
| <wsdl:port binding="tns:ModelAgentServiceSOAP" name="ModelAgentServiceSOAP">
| <soap:address location="http://localhost:9080/ModelAgentWeb/services/ModelAgentServiceSOAP"/>
| </wsdl:port>
| </wsdl:service>
| </wsdl:definitions>
|
All the classes are generated coorectly. However, the wsdl published by JBoss look like this
definitions name="ModelAgentService" targetNamespace="http://com.lei.nl/modelAgent" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://com.lei.nl/modelAgent" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://modelagent.lei.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
| <types>
| <xs:schema targetNamespace="http://com.lei.nl/modelAgent" version="1.0" xmlns:tns="http://com.lei.nl/modelAgent" xmlns:xs="http://www.w3.org/2001/XMLSchema">
| <xs:element name="ModelAgentRequest">
| <xs:complexType>
| <xs:sequence>
| <xs:element name="modelType" type="xs:string" />
| <xs:element name="modelName" type="xs:string" />
| <xs:element maxOccurs="unbounded" minOccurs="0" name="modelParameters" nillable="true" type="tns:ModelParameter" />
| </xs:sequence>
| </xs:complexType>
| </xs:element>
| <xs:element name="ModelAgentResponse">
| <xs:complexType>
| <xs:sequence>
| <xs:element name="returnCode" type="xs:string" />
| </xs:sequence>
| </xs:complexType>
| </xs:element>
| <xs:element name="gdxAttachment" nillable="true" type="xs:base64Binary" />
| <xs:complexType name="ModelParameter">
| <xs:sequence>
| <xs:element name="parameterName" type="xs:string" />
| <xs:element name="parameterValue" type="xs:string" />
| </xs:sequence>
| </xs:complexType>
| </xs:schema>
| </types>
| <message name="ModelAgentService_invoke">
| <part element="ns1:gdxAttachment" name="gdxAttachment" />
| </message>
| <message name="ModelAgentService_invokeResponse">
| <part element="ns1:gdxAttachment" name="gdxAttachment" />
| </message>
| <portType name="ModelAgentService">
| <operation name="invoke" parameterOrder="ModelAgentRequest gdxAttachment">
| <input message="ns1:ModelAgentService_invoke" />
| <output message="ns1:ModelAgentService_invokeResponse" />
| </operation>
| </portType>
| <binding name="ModelAgentServiceBinding" type="ns1:ModelAgentService">
| <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
| <operation name="invoke">
| <soap:operation soapAction="" />
| <input>
| <soap:body use="literal" />
| </input>
| <output>
| <soap:body use="literal" />
| </output>
| </operation>
| </binding>
| </definitions>
|
What happened here is the first parts of the request and response messages are lost, and cannot therefore not be read a client.
Has anyone any idea what i am doing wrong?
Thnak you
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262849#4262849
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262849
14 years, 11 months