.Net WCF Service and Java Client - Handling SOAP Fault - web-services

I am invoking a WCF web-service (SOAP based) using Java client. The client is generated using apache cxf wsdl2java utility.
When the invoked service responds with a fault, I am not able to handle it using catch (javax.xml.ws.soap.SOAPFaultException), though when I invoke the service using SoapUI I see a valid soap response with fault envelope.
Code Snippet:
try{
iServiceInterface.postDataToSPOnline(USERNAME, PASSWORD,loExpense); }
catch(SOAPFaultException soapEx){
try {
//Not Invoked
System.out.println(“SOAPFaultException”);
} catch(Exception exp) {
//Not Invoked
System.out.println(“Exception”);
} finally {
//Control reaches here post calling the service
System.out.println(“Finally”);
}
SoapUI response on invoking the service when fault is returned in response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-US">Object reference not set to an instance of an object.</faultstring>
<detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>Object reference not set to an instance of an object.</Message>
<StackTrace>at
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
<Type>System.NullReferenceException</Type>
</ExceptionDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Would appreciate your suggestions in handling this scenario.
Thanks,
Wajid

Related

The soap services is working in SOAPUI but its not working in mule soft web services consumer

I have web service wsdl file and its loaded successfully in SOAPUI. This is an request method.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:asi="http://siebel.com/asi/">
</soapenv:Header>
<soapenv:Body>
<asi:VSPOSCSyncRealTimeQueryById>
<PrimaryRowId>1-test</PrimaryRowId>
</asi:VSPOSCSyncRealTimeQueryById>
</soapenv:Body>
</soapenv:Envelope>
This above method is an working fine in SOAPUI. But when I try
to implement in mulesoft using web service consumer then the method is not populating.
This is an screen shot .
The above picture showing that the mule soft web service consumer is populating the only parameter without operation name but SOAPUI is populating both operation and parameter and its working. so any idea why mule soft web services consumer its not populating method name with parameter.
Thanks
Ishwar
I have created a sample as below and it is wokring as expected. I am not sure if you have selected the Operation in Web Service Component. Refer the following, hope this will work for you -
Webservice Consumer Component Operation
DataMapper
<flow name="muletestFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<set-variable variableName="first" value="#[message.inboundProperties.'http.query.params'.first]" doc:name="first"/>
<set-variable variableName="second" value="#[message.inboundProperties.'http.query.params'.second]" doc:name="second"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0%output application/xml%namespace ns0 http://tempuri.org/---
{
ns0#Add: {
ns0#intA: flowVars.first as :number
, ns0#intB: flowVars.second as :number
}
}]]></dw:set-payload>
</dw:transform-message>
<ws:consumer config-ref="Web_Service_Consumer" operation="Add" doc:name="Web Service Consumer"/>
</flow>

web service endpoint using cxf in jboss fuse

I'm using jboss fuse 6.1-final:
here is my simple route:
<route>
<from uri="cxf:bean:synchronousEndpoint"/>
<log message="Service invoked." />
<process ref="simpleProcessor"/>
</route>
and in the simpleProcessor I'm putting correct response(i.e corresponding JAXB object) to the context. But, it responds with fault:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Marshalling Error: java.lang.Object cannot be cast to org.w3c.dom.Element</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
here is stack trace:
Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to org.w3c.dom.Element
is there any hints or suggestions?
Bit hard to say without seeing some more code from the simpleProcessor. However it seems like you are using the wrong dataFormat parameter.
The cxf component has a dataFormat parameter which can be any of the following:
POJO: POJOs (Plain old Java objects) are the Java parameters to the
method being invoked on the target server. Both Protocol and Logical
JAX-WS handlers are supported.
PAYLOAD: PAYLOAD is the message payload (the contents of the
soap:body) after message configuration in the CXF endpoint is
applied. Only Protocol JAX-WS handler is supported. Logical JAX-WS
handler is not supported.
MESSAGE: MESSAGE is the raw message that is received from the
transport layer. It is not suppose to touch or change Stream, some of
the CXF interceptors will be removed if you are using this kind of
DataFormat so you can't see any soap headers after the camel-cxf
consumer and JAX-WS handler is not supported.
CXF_MESSAGE: New in Camel 2.8.2, CXF_MESSAGE allows for invoking the
full capabilities of CXF interceptors by converting the message from
the transport layer into a raw SOAP message
The default is POJO which means there is no XML being passed as a message Camel is passing objects. I suspect you might be trying to manipulate the response as XML and this is causing problems.
I ran into something similiar to this a while back where I was trying to convert the POJO into XML by trying to do a XPATH query on the XML when I was receiving a POJO.

Invocation of TIBCO web service from HP Service Manager is causing error

For the integration purpose, we need to consume a web service exposed by TIBCO in HP SM.
In HP SM, we consume a web service by using a utility called wsdl2js, which create JavaScript using wsdl url. I am able to use wsdl2js but when I invoke the web service, I am able to see request xml getting formed in SM but in response I am getting an error message"
Error calling method: doSoapRequest in class:com/hp/ov/sm/server/utility/SoapClient
Exception(com.sun.xml.messaging.saaj.SOAPExceptionImpl:
java.security.PirvilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
Invalid Content-type:text/html.Is this an error message instead of a SOAP response?
In the wsdl file, there are following schemas:
<?xml version="1.0" encoding="UTF-8"?>
<!--Created by TIBCO WSDL-->
<wsdl:definitions xmlns:ns1="http://www.tibco.com/schemas/TIGIaaS-IP085/WSDL and XSD/Schema.xsd4" xmlns:tns="http://xmlns.example.com/1372306950675/CreateUpdateIncidentImpl/BusinessProcesses/_00-InputChannels" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns0="http://www.tibco.com/schemas/TIGIaaS-IP085v0.2/WSDL and XSD/Schema.xsd2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/" name="Untitled" targetNamespace="http://xmlns.example.com/1372306950675/CreateUpdateIncidentImpl/BusinessProcesses/_00-InputChannels">
<wsdl:types>
<xs:schema xmlns="http://www.tibco.com/schemas/TIGIaaS-IP085v0.2/WSDL and XSD/Schema.xsd2" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.tibco.com/schemas/TIGIaaS-IP085v0.2/WSDL and XSD/Schema.xsd2" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="HPSM">
Could this error is because SM which is installed on a different unix server than TIBCO is not able to read schemas?
I have resolved this issue.
Issue was with SOAP Version. SOAP Version of wsdl provided by TIBCO was 1.2 and HP SM was expecting 1.1
SOAP 1.2 supports application/soap+xml, while SOAP 1.1 supports text/xml. That is why I was getting content-type error.

Reading web service response using ColdFusion

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<WSResponseHeader xmlns="http://cio.xxx.com/commonheader/v3" xmlns:ns2="http://newhorizon.xxx.com/ABCservice">
<WSCorrelationId>?</WSCorrelationId>
</WSResponseHeader>
</S:Header>
<S:Body>
<ns2:newOrderResponse xmlns="http://cio.XXX.com/commonheader/v3" xmlns:ns2="http://newhorizon.XXXX.com/ABCservice">
<ns2:ABCOrderResponse>
<ns2:headerStatus>ERROR</ns2:headerStatus>
<ns2:lineResponse>
<ns2:sourceSystemRefLineNum>1</ns2:sourceSystemRefLineNum>
<ns2:lineStatus>ERROR</ns2:lineStatus>
<ns2:lineError>
<ns2:errorCode>122</ns2:errorCode>
<ns2:errorMessage>Billing Category Code is required. </ns2:errorMessage>
</ns2:lineError>
</ns2:lineResponse>
</ns2:ABCOrderResponse>
</ns2:newOrderResponse>
</S:Body>
</S:Envelope>
I have a soap web service code in ColdFusion which invokes an external web service and my app will pass some rows to it. The above is the format of response that the application will send back. There can be multiple <ns2:lineResponse> type blocks. Some blocks will have error tags, some may have success tags.
How can I iterate through this response to extract details from error tag blocks only?
When I try to make loops, it is counting <ns2:headerStatus>ERROR</ns2:headerStatus> also as child node.

SOAP web-service - fake a server side error?

my iphone app is using soap web-services. I want to know how it would behave if the web-service returns a soap error?
I am using charles (HTTP Proxy) to catch the responses and modify the response before sending it to my iPhone app. What I'm trying to do is to modify a successful soap response, and turn it into a soap fault to see how my application behave.
QUESTION: How does a SOAP error response look like? (With restful all i had to do was to change the responseCode to 504, how can I achieve this with SOAP)?
How does a SOAP error response look like?
Here's an example of how a failed SOAP response might look like:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="en-US">The creator of this fault did not specify a Reason.</faultstring>
<detail>
<MyFault xmlns="http://schemas.datacontract.org/2004/07/ToDD" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<MyProperty>some value</MyProperty>
</MyFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
As you can see there's a special <Fault> node in the body of the SOAP response which could contain any XML describing the SOAP fault. The custom XML should be in the <detail> child node.