简体   繁体   中英

wcf service wsHttpBinding over internet

Hello trying to get my binding to work over internet. im using wsHttpBinding and trying to get it to work with soap. i've tried NetTcpBinding and got my functions to show in the wcftestclient over the internet with my public ip and forwared my port to the right computer, but i could not call any functions failing with: 在此处输入图片说明

and i dont think soap can be used with NetTcpBinding so i've been trying to make this config work

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service
        behaviorConfiguration="VenatoWCF.Behavior"
        name="VenatoWCF.WCFService">
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="VenatoWCF.IService"
          bindingConfiguration="Binding">
        </endpoint>
        <endpoint
          address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange">
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8734/WCF/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="VenatoWCF.Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <useRequestHeadersForMetadataAddress />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="Binding" >
          <security mode="Message">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>
</configuration>

this can be consumed by soap but this this config i cant get any respone with soap or wcftestclient.

soap: Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from ' http://(My External ip):8734/WCF/?wsdl' : failed to load external entity " http://(My External ip):8734/WCF/?wsdl"

thank you for answers

EDIT1 sorry wrong config file for thoose who where fast enough to see :/

EDIT2

found in my wsdl file that in the bottom i have <soap:address location="https://dendei:8734/WCF/" /> isent that one supposed to be the one soap connects too and need to be "https://(my external ip):8734/WCF/" ???

how can i change this one? in config file? or in my program?

EDIT3

stumbled on this site while searching UseRequestHeadersForMetadataAddressBehavior

and that solved it localy so i could have localhost in my baseaddress <add baseAddress="https://localhost:8734/WCF/"/>

and it worked with soap so i got back the address it tries to connect too

and worked over the net :)

but with UseRequestHeadersForMetadataAddressBehavior you have to use .NET 4.0

You error message says that you use this Url http://(My External ip):8734/WCF/?wsdl to connect to your service with WcfTestClient. But you defined a different Url in you config file. Have a look a your baseAddress. Try this Url http://(My External ip):8734/Venato/mex?wsdl

Alright got it to work if i switched to 4.0 and use UseRequestHeadersForMetadataAddressBehavior instead of trying to access the wsdl file and change the soap:address that points to the local address still dont know how to do that. :)

and the connection problem was in my computer firewall that blocked connection the router accepted the connection and my own computer blocked it xD

will edit my quest with the config that worked for me cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM