Link to home
Start Free TrialLog in
Avatar of SanjaySutar
SanjaySutarFlag for India

asked on

how to configure different port and service URL and clientBaseAddress ?

Hi,

I have a WCF Service (using WSDualHttpBinding) hosted on a machine. I am try to consume service from a different machine.

In the app.config i have added endpoint address as http://pc1/ServiceTest/Service1.svc  and clientBaseAddress as http://pc1/ServiceTest/Service1.svc

I am getting error while consuming service as metioned below :

Message: HTTP could not register URL http://+:80/ServiceTest/Service1.svc/ because TCP port 80 is being used by another application.
Avatar of Unflux
Unflux
Flag of United Kingdom of Great Britain and Northern Ireland image

You are receiving the provided message because you are attempting to register your server on port 80, which your local machine is currently using, and therefore has already registered, for use with web http requests.

To resolve this error simply specify a port number within your base address, for example:

<system.serviceModel>
	<services>
		<service name="MyNamespace.MyService">
			<clear />
			<endpoint
				address="dual"
				binding="WSDualHttpBinding"
				contract="MyNamespace.IMyService"
				/>
				<!-- 
					add other service endpoints with desired attributes as required
				-->
			<host>
				<baseAddresses>
					<add baseArress="http://pc1:8080/myservice" />
				</baseAddresses>
			</host>
		</service>
		<!--
			add other services as required
		-->
	</services>
</system.serviceModel>

Open in new window

Avatar of SanjaySutar

ASKER

Hi Unflux, thanx for the reply.

If WCF service and consuming application are on the same machine then adding port no. to clientBaseAddress is working.

But in this case my WCF service is hosted on some different machine.

So i am getting the error. Please take a look at the config file and correct me if am making any mistake.

I also tried to use different ports in service URL available on WCF service host machine, but all in vain.

<bindings>
      <wsDualHttpBinding>
        <binding name="ServerService" closeTimeout="00:30:00"
            openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" clientBaseAddress="http://pc1:1123/WSDualHttpBindingTest/Service1.svc">
          <readerQuotas maxDepth="32" maxStringContentLength="131072000" maxArrayLength="16384"
              maxBytesPerRead="51200" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:30:00" />
          
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default" />
          </security>
         
        </binding>
        
      </wsDualHttpBinding>
    </bindings>

<client>
      <endpoint address="http://pc1/WSDualHttpBindingTest/Service1.svc" binding="wsDualHttpBinding"
          bindingConfiguration="ServerService"
          contract="ServiceReference1.ServerService" name="ServerService">
              </endpoint>
    </client>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Unflux
Unflux
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have that already in config files.

Server Config

<endpoint address="http://localhost:2660/Service1.svc" binding="wsDualHttpBinding" contract="WSDualHttpBindingTest.IServerService" />

Open in new window



Client Config

<client>
      <endpoint address="http://localhost:2660/Service1.svc" />

Open in new window


<bindings>
      <wsDualHttpBinding>
        <binding name="ServerService" clientBaseAddress="http://localhost:8080/Service1.svc" />

Open in new window



Still I am getting error as i have mentioned earlier.