cancel
Showing results for 
Search instead for 
Did you mean: 

soapui mockservice https

SOLVED
Occasional Contributor

soapui mockservice https

System.ArgumentException
The provided URI scheme 'http' is invalid; expected 'https'.
Parameter name: via
   at System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)
   at System.ServiceModel.Channels.HttpChannelFactory`1.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via)
   at System.ServiceModel.Channels.HttpsChannelFactory`1.OnCreateChannelCore(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.OnCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverRequest.CreateInnerChannelBinder(EndpointAddress to, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at ForceDevelopmentServices.SOAAccessions.AccessionsServiceClient.ForceDevelopmentServices.SOAAccessions.AccessionsService.retrieveCommissionAgreement(retrieveCommissionAgreementRequest request) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\Service References\SOAAccessions\Reference.cs:line 1284
   at ForceDevelopmentServices.SOAAccessions.AccessionsServiceClient.retrieveCommissionAgreement(FilterCriteria Filter) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\Service References\SOAAccessions\Reference.cs:line 1290
   at ForceDevelopmentServices.ServiceCode.Common.SOA.Accessions.GetCommissionAgreementDaily(Int32 days) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\ServiceCode\Common\SOA\Accessions.cs:line 38
   at ForceDevelopmentServices.ServiceImplementation.SOA.AccessionsData.GetCommissionAgreementDetailDaily(Int32 days, IAccessions soaCall) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\ServiceImplementation\SOA\AccessionsData.svc.cs:line 37
   at FDSTest.SOA.AccessionsDataTests.Validates_notEmptyList_whenMockService_GetCommissionAgreementDetailDaily() in C:\Repos\usaf-forcedevelopmentservices\FDSTest\SOA\AccessionsDataTests.cs:line 109

Hello, 

I imported a wsdl into SOAP UI OS.  

I created a mock Service. 

 

When I turn on the mock Service and browse to it, I get a http version of wsdl. 

 

I looked around to find a way to go through HTTPs using this link : https://www.soapui.org/soap-mocking/tips-and-tricks/securing-mockservices-with-ssl.html.

 

No issue so far. 

 

With SoapUI and its mock service capability, I could use it as a way to test my application without having to develop a fake service.  

 

So with the create mock Service from SOAP UI, I used the http url provided by SOAPUI.  

 

But with the wsdl, it needs to go through HTTPs only.  

 

While using Visual Studio, here is a part of the app.config for test.

 

 <system.serviceModel>
    <client>
      <endpoint address="http://mymachine:8088/mockAccessionsServiceSOAP" binding="customBinding" bindingConfiguration="CustomSoaBinding" contract="SOAAccessions.AccessionsService" name="AccessionsServiceSOA" />

 

When I leave the app.config alone, I get this type of error:

 

 

System.ArgumentException
The provided URI scheme 'http' is invalid; expected 'https'.
Parameter name: via
   at System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)
   at System.ServiceModel.Channels.HttpChannelFactory`1.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via)
   at System.ServiceModel.Channels.HttpsChannelFactory`1.OnCreateChannelCore(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.OnCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverRequest.CreateInnerChannelBinder(EndpointAddress to, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at ForceDevelopmentServices.SOAAccessions.AccessionsServiceClient.ForceDevelopmentServices.SOAAccessions.AccessionsService.retrieveCommissionAgreement(retrieveCommissionAgreementRequest request) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\Service References\SOAAccessions\Reference.cs:line 1284
   at ForceDevelopmentServices.SOAAccessions.AccessionsServiceClient.retrieveCommissionAgreement(FilterCriteria Filter) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\Service References\SOAAccessions\Reference.cs:line 1290
   at ForceDevelopmentServices.ServiceCode.Common.SOA.Accessions.GetCommissionAgreementDaily(Int32 days) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\ServiceCode\Common\SOA\Accessions.cs:line 38
   at ForceDevelopmentServices.ServiceImplementation.SOA.AccessionsData.GetCommissionAgreementDetailDaily(Int32 days, IAccessions soaCall) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\ServiceImplementation\SOA\AccessionsData.svc.cs:line 37
   at FDSTest.SOA.AccessionsDataTests.Validates_notEmptyList_whenMockService_GetCommissionAgreementDetailDaily() in C:\Repos\usaf-forcedevelopmentservices\FDSTest\SOA\AccessionsDataTests.cs:line 109

 

When I added the s at the end of http, I get this error. 

 

 

System.ServiceModel.CommunicationException
An error occurred while making the HTTP request to https://mymachine:8088/mockAccessionsServiceSOAP. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ForceDevelopmentServices.SOAAccessions.AccessionsService.retrieveCommissionAgreement(retrieveCommissionAgreementRequest request)
   at ForceDevelopmentServices.SOAAccessions.AccessionsServiceClient.ForceDevelopmentServices.SOAAccessions.AccessionsService.retrieveCommissionAgreement(retrieveCommissionAgreementRequest request) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\Service References\SOAAccessions\Reference.cs:line 1284
   at ForceDevelopmentServices.SOAAccessions.AccessionsServiceClient.retrieveCommissionAgreement(FilterCriteria Filter) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\Service References\SOAAccessions\Reference.cs:line 1290
   at ForceDevelopmentServices.ServiceCode.Common.SOA.Accessions.GetCommissionAgreementDaily(Int32 days) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\ServiceCode\Common\SOA\Accessions.cs:line 38
   at ForceDevelopmentServices.ServiceImplementation.SOA.AccessionsData.GetCommissionAgreementDetailDaily(Int32 days, IAccessions soaCall) in C:\Repos\usaf-forcedevelopmentservices\ForceDevelopmentServices\ServiceImplementation\SOA\AccessionsData.svc.cs:line 37
   at FDSTest.SOA.AccessionsDataTests.Validates_notEmptyList_whenMockService_GetCommissionAgreementDetailDaily() in C:\Repos\usaf-forcedevelopmentservices\FDSTest\SOA\AccessionsDataTests.cs:line 109

System.Net.WebException
The underlying connection was closed: An unexpected error occurred on a send.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

System.IO.IOException
The handshake failed due to an unexpected packet format.
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)

 

 I then change the binding from the custombinding to a basicHttpBinding, this error appear most promising considering I could see some of the data from my mock service. 

 

+		$exception	{"The content type application/soap+xml;charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:v2=\"http://mil.dod.af.A1.personnel.dataservices.accessions/v2.0\" xmlns:mil=\"http://mil.dod.af.A1.personnel.dataservices.cleartext\">\n   <soap:Header/>\n   <soap:Body>\n      <v2:retrieveCommissionAgreementResponse>\n         <!--Zero or more repetitions:-->\n         <CommisionAgreement Id=\"123\">\n            <!--Optional:-->\n            <v2:Adn>\n               <!--Optional:-->\n               <mil:Code>123</mil:Code>\n               <!--Optional:-->\n               <mil:Value>456</mil:Value>\n            </v2:Adn>\n            <!--Optional:-->\n            <v2:CompCategory>\n               <!--Optional:-->\n               <mil:Code>123</mil:Code>\n               <!--Optional:-->\n               <mil:Value>456</mil:Value>\n            </v2:CompCategory>\n            <!--Optional:-->\n            <v2:EffectiveBeginDate>2001-01-10</v2:EffectiveBeginDate>\n            <!--Optional:-->\n            <v2:SourceOfCommission>\n               <!--Optional:-->\n       '."}	System.ServiceModel.ProtocolException

I do not have the option to update the original wsdl as it was provided to me as a service we consume for use. 

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: soapui mockservice https

Since no one replied, I eventually figured it out. 

 

Steps taken: 

1. Start up mock Service.

2. Create a console app. 

3. Added Service Reference to mock Service wsdl.

4. With this new Service Reference, app.config is generated. 

5. Copied over appropriate binding and client endpoint to test project app.config.

6. Ran test.

 

7 REPLIES 7
Occasional Contributor

Re: soapui mockservice https

Since no one replied, I eventually figured it out. 

 

Steps taken: 

1. Start up mock Service.

2. Create a console app. 

3. Added Service Reference to mock Service wsdl.

4. With this new Service Reference, app.config is generated. 

5. Copied over appropriate binding and client endpoint to test project app.config.

6. Ran test.

 

New Contributor

Re: soapui mockservice https

Hi minoseah629,

 

I am quite new soapui user, I have to test mutual connection to get to know why connection is not working, if the problem is in my keystore or rather it's problem of certificate on the service provider side. I have installed version 5.4 I have configured properties to use SSL but it doesn't work for me via https.

 

Occasional Contributor

Re: soapui mockservice https

@miras, have you reviewed this link: 

https://www.soapui.org/soap-mocking/tips-and-tricks/securing-mockservices-with-ssl.html#_ga=2.800565...

 

I am not sure what you mean by a mutual connection.

New Contributor

Re: soapui mockservice https

Hello minoseah629,

 

Yes, it's first document I've studied.

Generally I have service provider for one integration and it requires mutual connection (present certificate first). The problem is in my kestore or on service provider side, I need to be sure so I want to emulate service provider service with soapui (mock service). It works perfect for http but I would expect after mock service is enabled in soapui properties, automatically https connection is open but it doesn't.

Occasional Contributor

Re: soapui mockservice https

i suggest starting up a new discussion because i didnt have the issue you are describing.  

New Contributor

Re: soapui mockservice https

The article

https://www.soapui.org/soap-mocking/tips-and-tricks/securing-mockservices-with-ssl.html

needs updating.  For windows the steps are:

 

keytool -genkey -alias soapui -keyalg RSA -keystore mock.keystore

keytool -importkeystore -srckeystore mock.keystore -destkeystore mock.keystore -deststoretype pkcs12

keytool -exportcert -keystore mock.keystore -file soapui.cer -alias soapui

keytool -import -alias soapui -file soapui.cer -keystore mock.truststore

 

and finally: the url port is wrong in the docs.

Change the URL from the one indicated in the Screen shot in the link above to:

https:/localhost:8443/...

and double finally:

NOTE: the URL is case sensitivie and only works for lower case, so if your PC name is MYPC, the url should be https://mypc:8443/

 

Visitor

Re: soapui mockservice https

SOLVED:

 

Not a problem on the SoapUI (mock server) side but in the SOAP client (Windows) side. Instead of just importing the .cer file in Windows, it is necessary to import both the public and private keys. To do that, copy the mock.keystore file to mock.p12 file and then import it to the Windows machine running the SoapUI client.

In C#, create the SoapUI Client in this way:

 

WSHttpBinding myBinding = new WSHttpBinding();
myBinding.Security.Mode = SecurityMode.Transport;
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
EndpointAddress ea = new EndpointAddress(<URL address of the mock service, including the port>);
var soapClient = new port_TFEDI_typeClient(myBinding, ea);

 

Then set the certificate by calling soapClient.ClientCredentials.ClientCertificate.SetCertificate() with the proper parameters (they will depend on the certificate data, store location and store name in the client machine).

Have in mind that port_TFEDI_typeClient is the name of a service reference class that will depend on each project.

Finally, check the app.config file to be sure that the <client><endpoint> address matches the URL address of the mock service, including the port (as defined in the creation of the variable ea in the previous example).

 

---

 

Nope, not working for me after following your instructions two times. There's a problem in the second command, since it seems that it tries to use the same source and destination file (mock.keystore), bypassed by using a temp destination (mock.keystore.temp) and then erasing the source file and renaming the temp file to mock.keystore again.

 

Apart of that, everything works: keystore and truststore are generated, public certificate is generated and successfully imported into Windows Certificates Manager (dunno if that's the right name, but anyway, the windows utility for managing certs).

 

Then I configure SoapUI SSL settings by enabing mock SSL, setting keystore file and Mock KeyStore to the generated keystore file (mock.keystore), and the Mock TrustStore to the generated truststore (mock.truststore), always with their proper paths. I set all the passwords and finally I enable the client authentication. I've checked that it doesn't work if I set a wrong filename or wrong password, in these cases I get an error when starting the mock service. So I assume that all the settings are correct. Finally, the Mock port is set to -say- 880.

 

After that I restart SoapUI and I lauch the mock service, running on a different port to 880 because if I set the same ports I get an error (port already open).

 

My client is developed in C# with this simple code:

 

port_TFEDI_typeClient soapClient = new port_TFEDI_typeClient("Service_EME_Port", "https://localhost:880/Service/ServiceEME");
soapClient.ClientCredentials.ClientCertificate.SetCertificate("CN=localhost, OU=localhost, O=localhost, L=Unknown, S=Unknown, C=es", StoreLocation.LocalMachine, StoreName.TrustedPeople);
soapClient.Open();

ResponseMessageType response = soapClient.request();

 

Basically, it creates a new client object using https as transport and pointing to the url (https://localhost:880/Service/ServiceEME) where SoapUI Mock service is bound. Then it adds the client certificate (I see in the debug that the real certificate is properly retrieved) and then opens the client and makes a client request.

 

The request fails, I get an error  "javax.net.ssl.SSLHandshakeException: null cert chain" in the SoapUI jetty log and then an "Unable to set a secure channel with localhost:880" in the client side.

 

I've checked that the same code works if I configure SoapUI to not performing a client authentication and I've checked that it is not a negotiation problem (if I only enable SSL3 in the client side, I get an error in SoapUI telling that it cannot negotiate with a SSL3 client), apart of -as said- being sure that the keystores, truststores and passwords are correct in SoapUI config (by setting wrong values and getting a proper error).

 

At this point, I don't know what else to test.

New Here?
Join us and watch the welcome video:
Watch the New Interview
APITestingMistake#2
Top Kudoed Authors
Top Kudoed Posts