How to Handle Fault Contracts in Biztalk - wcf

ERROR:
<s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action '<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="MyOperation" Action="http://tempuri.org/class/MyOperation" />
</BtsActionMapping>' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault>
operation used in WCF-custom send port:
<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="MyOperation" Action="http://tempuri.org/Class/MyOperation" />
</BtsActionMapping>
I used the generated binding file when I consumed the webservice.
Webservice code:
public interface Class
{
[OperationContract]
[FaultContract(typeof(FaultClass))]
Response Myoperation(List<getattributes> getattributes);
}
When I try to handle the faultcontract this mismatch is showing up. or am I missing something here.

The Action of a WCF send adapter is based on the SOAP action header (or BtsActionMapping) configuration in the WCF send adapter and/or the properties BTS.Operation and BTS.Action.
It looks like the WCF adapter is unable to match the action with the configured action in your send adapter. As a result of this, the action is set to this string:
<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Operation Name="MyOperation" Action="http://tempuri.org/class/MyOperation" /> </BtsActionMapping>
Did you specify the BTS.Operation = "MyOperation" in the context of your message?
Few (other) possibilities:
1. Write the action in the context of the message
BTS.Operation = "MyOperation"
and configure ActionMapping in the SOAP action header configuration:
<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="MyOperation" Action="http://tempuri.org/class/MyOperation" />
</BtsActionMapping>
2. Write the action in an orchestration and leave the SOAP action header configuration empty:
OutboundMessage(WCF.Action)= "http://tempuri.org/Class/MyOperation";
3. Configure a fixed action in the SOAP action header configuration in the adapter configuration:
http://tempuri.org/Class/MyOperation
A great article on MSDN related to SOAP actions configuration for send ports can be found here: Specifying SOAP Actions for WCF Send Adapters

Related

Adress Mismatch at the end point dispatcher

I have a WCF service which using the Web-Http Adapter through BizTalk. When I am trying to call the wcf service. I am getting the error below.
<?xml version="1.0"?>
-<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
-<Code>
<Value>Sender</Value>
-<Subcode>
<Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">
a:DestinationUnreachable
</Value>
</Subcode>
</Code>
-<Reason>
<Text xml:lang="en-US">The message with To 'https://biztalkt01.abc.org/ELIMS/ELIMS-CGA1/Service1.svc/?specimenid=abc001234'' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text>
</Reason>
</Fault>
When I google for this error I can see this code needed to be added in to the service code
[ ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]
But not sure where is the service code for this service.
The above folder is wat I am seeing with respect to the service created in C:\inetpub\wwwroot\ELIMS\ELIMS-CGA1. Does the code needs to added in to any of these files or the files in the App_Data.
You need to configure your port settings properly for the adapter. This is not related to the WCF configuration files, but to the receive location settings in BizTalk itself. You have to set up the Address and the BtsHttpUrlMapping elements; see https://msdn.microsoft.com/en-us/library/jj572859.aspx for more information on these particular elements.

(vb.net) send a SOAP envelope

I consume a web service (available there) and I need to generate and to send a SOAP envelope, but it's not something i do understand.
I've found this example: http://macunsw.wordpress.com/2010/11/19/vb-net-example-for-calling-web-service-by-posting-soap-xml/
but still, i do not get it, the envelope i need to send is like that:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>cid:20100066603-01-F001-1.zip</contentFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
Can someone help? thx
Since you're using VB.Net you're not required to handle the SOAP services on your own.
Add the WSDL path http://...?wsdl as a remote Service:
in the Solution Explorer rightclick your project
Choose Add Service Reference from the context menu
enter the path to WSDL in the Address field & Click Go
the billService should be found
choose a namespace, i.e. Sunat
From now on you can access the service as a simple object:
Dim billService As New Sunat.billServiceClient
billService.sendBill(fileName, contentFile)
billService.sendSummary(fileName, contentFile)
billService.getStatus(ticket)

How to get real result from AxisEngine

I'm trying to implement my specific transport for WSO2 ESB based on some proprietary binary protocol. From protocol specification I need acknowledge every packet I receive only if I'm 100% sure that it will be processed in future. For those reasons some persistent store must be used.
I want to implement that protocol logic via WSO2 ESB sequence that gets protocol packets/messages and stores them to temporary messageStore which is used as a queue in producer/consumer pattern (where producer is transport itself and consumer is my packet processor).
I have to be sure that my packet got to the messageStore before sending acknowledge to the client. But AxisEngine.receive() does always return CONTINUE even if message store is not available.
The configuration of the proxy is:
<proxy name="MyProxyService">
<target>
<inSequence>
<store messageStore="MyStore" sequence="onStoreSequence"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
<makefault version="soap11" response="true">
<code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
<reason expression="get-property('ERROR_MESSAGE')"/>
</makefault>
<send/>
</faultSequence>
</target>
</proxy>
The code I use in transport is:
MessageContext msgContext = confContext.createMessageContext();
AxisConfiguration axisConf = confContext.getAxisConfiguration();
try {
msgContext.setTransportIn(axisConf.getTransportIn(transportName));
msgContext.setTransportOut(axisConf.getTransportOut(transportName));
msgContext.setIncomingTransportName(Constants.TRANSPORT_LOCAL);
msgContext.setAxisService(axisConf.getService("MyProxyService"));
msgContext.setEnvelope(TransportUtils.createSOAPMessage(msgContext));
msgContext.setServerSide(true);
Handler.InvocationResponse response = AxisEngine.receive(msgContext);
log.error(String.valueOf(response));
} catch (Exception e) {
log.error("ERROR", e);
}
The behaviour I want to have is what I see in HTTP transport: http request from the client (SOAP UI) is translated to Axis2 MessageContext and delivered to MyProxyService. If everything is ok - I get positive response, otherwise - error code and SOAP fault.
After additional investigation I can say that idea behind HTTP transport request/response is that for sending response the HttpSender not HttpReceiver is used. HttpReceiver gets request from HTTP connection, sets link to HTTP connection to the message context, uses AxisEngine.receive() to deliver message to the ESB and returns.
HTTP response itself is received via HttpSender, identified as response to the previous request (via empty To header) and sent to the connection referenced from the message context.

Error accesing published WS proxy in WSO2 ESB 4.6: EPR not found

I deployed exactly the same WS-proxy in 4.5.1 and 4.6. With 4.5.1 it works correctly, but with 4.6 I get:
ERROR - AxisEngine The endpoint reference (EPR) for the Operation not found is /services/registro.registroHttpSoap11Endpoint and the WSA Action = . If this EPR was previously reachable, please contact the server administrator.
The source is the following:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="registro" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:15080/SIGEM_RegistroPresencialWS/services/ServicioRegistroWebService"/>
</endpoint>
</target>
<publishWSDL uri="http://localhost:15080/SIGEM_RegistroPresencialWS/services/ServicioRegistroWebService?wsdl"/>
<description></description>
</proxy>
What do I have to do for 4.6. to make it work?
Thanx.
To enhance ESB performance pass-through transport has been enabled by default starting from ESB 4.6.0 version that is not the case for ESB 4.5.1. It seems your proxy service depends on SOAP body based dispatching but pass-through transport does not support for SOAP body based dispatching. SOAP body based dispatching build the message body and use first element's local name for dispatching which effect to proxy performance badly that is the reason it was not supported in pass-through transport. We are in a process to fix this limitation for future ESB releasees without loosing any advantage of pass-through transport.
BTW for the moment you can use one of the following workarounds.
When sending a messages to the proxy service append operation name to the endpoint URL
e.g - http://serverName/app/serviceName/operationName
Modify client level code to send expected SOAPAction value ( like Try-It case)
I'm not sure your backend service's WSDL defined "" as the value of SOAPAction if that is the case you may modified the backend service to have value other than "" per each operation. AS an example for JAX-WS services you can use #WebMethod annotation for this.
e.g - #WebMethod(action="XXXX")
Note : In case if your backend WSDL defining a value other than "" for SOAPAction while your client send message with SOAPAction="" then it's a violation of service contract by the client and need to be fixed on client level.
I have faced the same problem with wso2 ESB 4.7 and the web service is also developed by me for the company.
What worked for me is adding soapAction attribute to wsdl soap:operation element like below.
<soap:operation soapAction="http://localhost:8080/MyWebApp/services/hello" style="document"/>

WSO2 Proxy Service URL not working with SOAPUI

We have CXF based SOAP web services and we are hitting these services from SOAP UI with no problem. With one of these services, I setup a ProxyService on barebone WSO2 ESB 4.6.0. The proxy service seems to be working with the "Try It" option from the admin console. When I try to access it from SOAPUI, the WSO2 ESB starts complaining that
"The endpoint reference (EPR) for the Operation not found is /services/HelloWorldProxyService and the WSA Action = . If this EPR was previously reachable, please contact the server administrator."
Now, when I change the endpoint URL in SOAPUI as http:// hostname:8280/services/service-name.port-name/operation-name things start to work.
Does anyone know how to fix this issue? Are there configuration options on the WSO2 ESB which will let us use traditional SOAPUI with WSO2 ESB?
You can point the proxy service url(you can view this, via service dashboard of the particular proxy) in soapui and for the "action", in the insequence of the proxy define a property call;
. header name="Action" value="soap action"
Here is the guide on vailable properties
http://wso2.org/project/esb/java/3.0.0/docs/properties_guide.html
I have the same problem if I put operation1 at the end of WS URI (http://somedomain.com/WebServiceProxyName/operation1), but post a SOAP message body with constructs for another operation(operation2,3,4,5...) it works!!!
Sample
POST http://somedomain.com/..../operation1 HTTP/1.1
....
....
<soap:Envelope ...>
<soap:Header/>
<soap:Body>
<ws:operation2>
</ws:operation2>
</soap:Body>
</soap:Envelope>
Try to change the (original) WSDL and put the soapAction there:
You can define it as an attribute of the http://schemas.xmlsoap.org/wsdl/soap/:operation element in the binding section, e.g.
<wsdl:binding name="healthcheck-1.0.0SOAP" type="tns:HealthCheck100PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="doHealthCheck">
<soap:operation soapAction="http://www.xyz.ch/healthcheck-1.0.0/doHealthCheck"/>