Can't consume GlassFish generated WSDL from .NET - wcf

I am trying to add a web service reference to my C# application in Visual Studio. The web service is hosted on Sun's GlassFish server. Unfortunately Visual Studio produces the following warning when I try to add the service reference:
Custom tool warning: The following Policy Assertions were not Imported:
XPath://wsdl:definitions/wsdl:binding[#name='SecurityWebServicePortBinding']/wsdl:operation[#name='RegisterUser']
Assertions:
<wsat:ATAlwaysCapability xmlns:wsat='http://schemas.xmlsoap.org/ws/2004/10/wsat'>..</wsat:ATAlwaysCapability>
Apparently it cannot understand policy assertions in the WSDL published by the GlassFish server. Here's an excerpt from the WSDL:
<?xml version='1.0' encoding='UTF-8'?>
<definitions
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://test/securityservice.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://test/securityservice.wsdl"
name="SecurityService">
<wsp:Policy xmlns:wsat="http://schemas.xmlsoap.org/ws/2004/10/wsat" wsu:Id="SecurityWebServicePortBinding_AuthenticateUser_WSAT_Policy">
<wsat:ATAlwaysCapability />
<wsat:ATAssertion xmlns:ns1="http://schemas.xmlsoap.org/ws/2002/12/policy" wsp:Optional="true" ns1:Optional="true" />
</wsp:Policy>
<wsp:Policy xmlns:wsat="http://schemas.xmlsoap.org/ws/2004/10/wsat" wsu:Id="SecurityWebServicePortBinding_RegisterUser_WSAT_Policy">
<wsat:ATAlwaysCapability />
<wsat:ATAssertion xmlns:ns2="http://schemas.xmlsoap.org/ws/2002/12/policy" wsp:Optional="true" ns2:Optional="true" />
</wsp:Policy>
...
<binding name="SecurityWebServicePortBinding" type="tns:SecurityWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<operation name="RegisterUser">
<wsp:PolicyReference URI="#SecurityWebServicePortBinding_RegisterUser_WSAT_Policy" />
<soap:operation soapAction="RegisterUser" />
<input>
<wsp:PolicyReference URI="#SecurityWebServicePortBinding_RegisterUser_WSAT_Policy" />
<soap:body use="literal" />
</input>
<output>
<wsp:PolicyReference URI="#SecurityWebServicePortBinding_RegisterUser_WSAT_Policy" />
<soap:body use="literal" />
</output>
<fault name="UsernameExistsException">
<soap:fault name="UsernameExistsException" use="literal" />
</fault>
</operation>
</binding>
...
</definitions>
If I remove all the policy elements from the WSDL, Visual Studio is able to consume the service without any problems (in fact earlier I used to write the WSDL by hand and never put the policy statements). So my questions are:
Why is GlassFish insisting on adding the policies? Is there any way to suppress them?
Why is Visual Studio not able to consume the WSDL with the policies?

ws-AT (Atomic Transactions) seems to be part of the SOAP specification which WCF does not know about.
There is some information here - http://schemas.xmlsoap.org/ws/2004/10/wsat/
Update: Actually WCF is aware of the ws-AT spec, but doesn't support it fully (http://schemas.xmlsoap.org/ws/2004/10/wsat/). I suppose this is because WCF has alternatives which use OleTransactions.

Ok, I figured out why GlassFish is adding the ws-AT policies. My web service is being generated using an EJB (see below):
#Stateless
#WebService
public class SecurityWebService {
...
}
Since the default transaction attribute for a stateless EJB method is REQUIRED, GlassFish is making the web service method transactional too (see here for details). Not the behavior I want, but that's how it is!

Related

Is there any way how to ensure basic authentication for REST services deployed in latest wso2ei 6.4.0?

I want to use WSO2EI 6.4.0 as a proxy for SOAP and REST services authentication platform (later maybe authorization).
I found solution in documentation of wso2 (https://docs.wso2.com/display/EI640/Applying+Security+to+an+API), but unfortunately it is not working.
Adding "handler" element into service definition
<handlers>
<handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>
results into exception in design time (eclipse):
Invalid mediator <handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/> 1d6bbce1-08e3-42d5-b550-6a4e224b0028.xml /.tmp/.org.wso2.developerstudio.eclipse.esb line 15 org.wso2.developerstudio.eclipse.gmf.esb.diagram.synapseerror
Ignoring and deploying such API, makes the API stop working.
Could anyone help please?
The way you are trying to add the Basic authentication for API in WSO2EI 6.4.0 is correct. Developer studio will give a warning as you mentioned, but it should not be an issue. Developer studio will allow setting the handler regardless of the warning and you should be able to create a Composite Application which includes the API and deploy it to ESB. Following is a sample API with the RESTBasicAuthHandler.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/testapi" name="testapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" protocol="https" url-mapping="/*">
<inSequence>
<send>
<endpoint name="testapi_EP">
<http uri-template="http://localhost:8080/testapi"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
<handlers>
<handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>
</api>

MessageSecurityException for WCF customBinding UsernameOverTransport for WSSE

I need to implement a WCF service that conforms to the specs set forth by Phase II CORE 270 Connectivity Rule.
I generated the service using svcutil.exe and the supplied wsdl.
Given that we had chosen to handle security through username/password over SSL and the requirement for SOAP 1.2 addressing, I configured the service as a
customBinding:
<customBinding>
<binding name="ServiceBinding">
<security
authenticationMode="UserNameOverTransport"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
</security>
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
</customBinding>
The WSDL produced matches that of the WSDL provided by the spec. Using a supplied soap message:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="true">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-21621663">
<wsse:Username>bob</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-usernametoken-profile-1.0#PasswordText">bobPW</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns1:COREEnvelopeRealTimeRequest
xmlns:ns1="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd">
<PayloadType> X12_270_Request_005010X279A1004010X092A1</PayloadType>
<ProcessingMode>RealTime</ProcessingMode>
<PayloadID>f81d4fae-7dec-11d0-a765-00a0c91e6bf6</PayloadID>
<TimeStamp>2007-08-30T10:20:34Z</TimeStamp>
<SenderID>HospitalA</SenderID>
<ReceiverID>PayerB</ReceiverID>
<CORERuleVersion>2.2.0</CORERuleVersion>
<Payload><![CDATA[ISA*00* *00* *ZZ*NEHEN780 *ZZ*NEHEN003 ...IEA*1*000000031]]></Payload>
</ns1:COREEnvelopeRealTimeRequest>
</soapenv:Body>
</soapenv:Envelope>
and SoapUI, I am receiving a
System.ServiceModel.Security.MessageSecurityException, System.ServiceModel,
Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.
It would seem that the service does not understand the wsse namespace prefix as if I flip the namespace prefix to o the service does not have an issue with the request.
EDIT
I cannot seem to find the mismatch in the binding or an issue with their message indicating I am chasing up the wrong tree. Any other potential leads would be helpful. Is there a way to make a custom binding with SOAP 1.2 addressing inter-operable with the provided SOAP message?

Unable to generate WSDL 1.1 for this service

I have a wsdl (that works) and I've generated boilerplate code from it but wish to use my original wsdl not the auto generated one but on changing useOriginalwsdl to true I get errors. There is absolutely no documentation in the Axis website regarding this property so I have followed the steps here:
useOriginalwsdl=true is not working in axis2
specifically:
My services.xml has the same name as the wsdl service name
I have called my wsdl service.wsdl and put it in the META-INF folder (I also tried it with the service name)
But I get the error Unable to generate WSDL 1.1 for this service
Below is my folder structure:
.\com
.\lib
.\META-INF
services.xml
service.wsdl
My services.xml is:
<?xml version="1.0" encoding="UTF-8"?><!-- This file was auto-generated from WSDL -->
<!-- by the Apache Axis2 version: 1.6.2 Built on : Apr 17, 2012 (05:33:49 IST) -->
<serviceGroup>
<service name="MyService">
<messageReceivers>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="com.neil.systems.ServiceMessageReceiverInOut"/>
</messageReceivers>
<parameter name="ServiceClass">com.neil.webservice.MyService</parameter>
<parameter name="useOriginalwsdl">true</parameter>
<parameter name="modifyUserWSDLPortAddress">false</parameter>
<operation name="Provision" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://xmlns.neil.com/systems">
<actionMapping>http://xmlns.neil.com/systems/Provision</actionMapping>
<outputActionMapping>http://xmlns.neil.com/systems/ProvisionResponse</outputActionMapping>
</operation>
</service>
</serviceGroup>
My service.wsdl, the relevant part is:
<wsdl:service name="MyService">
Note, I changed a couple of things in the services.xml to reduce the size so any obvious errors is just down to my cutting.

Changing which queues are used for NServiceBus Pub/Sub scenario

I'm new to NServiceBus and I'm trying to use it with IIS and SignalR. I have a working scenario but I'm curious how the client chooses which queues to publish to. I've noticed (by stopping IIS and running the publisher) that the message gets published to a system.web queue. I assume this is because my endpoint is being started by ASP.Net or something similar. However, this seems like a really generic queue to use and I would like to use application specific queue names. How do I specify which queues the publisher uses? I've changed the endpoint on the SignalR application but it doesn't seem to make much of a difference.
Here is my client config:
[EndpointName("signalbus.web")]
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
{
}
Here is my app.config from the publisher:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
<section name="TransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core"/>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<connectionStrings>
<add name="NServiceBus/Persistence" connectionString="Url = http://localhost:9090" />
</connectionStrings>
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
<TransportConfig MaximumConcurrencyLevel="5" MaxRetries="2" MaximumMessageThroughputPerSecond="0"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="SignalBus.Messages" Endpoint="signalbus.web" />
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
When you configure the bus:
Configure.With().DefineEndpointName("MyAppName")
Edit
I'm a little confused based on your posted code and your comments. Are you hosting the subscriber in IIS/ASP.Net? If so, I think EndpointConfig will get ignored, as (AFAIK) it is only used via the NSB Host.
See this link for configuring the Bus in your own process (or ASP.Net):
http://docs.particular.net/nservicebus/hosting-nservicebus-in-your-own-process-v4.x
Also, you shouldn't need to reference the subscriber endpoint in your publisher's config--it needs no knowledge of its subscribers. It gets that via RavenDB or whatever subscription storage you are using.

WCF how to use WS addressing standard namespace: “http://www.w3.org/2005/08/addressing”

Calling the wsdl of my WCF web service, I read
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
But I need to set
xmlns:wsa="http://www.w3.org/2005/08/addressing
Any idea?
tow liines below the namespace you need is defined as wsa10. what counts is which prefix is used inside the WSDL, is it wsa or wsa10. If it is wsa10 then you are ok. If not use a custom binding and set:
<textMessageEncoding messageVersion="SOAP11WSAddressing10" />