简体   繁体   中英

Forcing WSDL in WCF WebService to use Relative Paths

Is there a way to make the schema location in my WSDL relative instead of absolute?? I have been searching for a solution to this, Im learning more about Wsdl generation along the way but I haven't found where I can configure this part of my Wsdl (see highlighted).

Partial WSDL Absolute Path vs.

Partial WSDL Relative Path

Im looking hoping to make this a relative path.

I believe there is probably a way to force this in the webconfig, I just haven't been able to find the solution myself online yet. Any help would be great appreciated if this is possible. If it's not possible, I'll accept that as a solution as well. Thanks!

Sorry for the late return on this. I was pulled aside for a few other issues. So for my solution I had to create my own WSDL and save it locally. Basically you can start with the WebService generated one, and just save it off as .WSDL file. Edit how you need too. If you need relative paths like I did, I simply added the relative paths and saved it in the root of the webservice application. It went from this:

using the standard link http://localhost:52038/Service1.svc?wsdl
-<xsd:schema targetNamespace="http://tempuri.org/Imports">

   <xsd:import namespace="http://tempuri.org/"schemaLocation="http://localhost:52038/Service1.svc?xsd=xsd0"/>

   <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" schemaLocation="http://localhost:52038/Service1.svc?xsd=xsd1"/>

</xsd:schema> 

To a local WSDL I save and changed the schemaLocations to relative paths like so:

-<xsd:schema targetNamespace="http://tempuri.org/Imports">

   <xsd:import namespace="http://tempuri.org/" schemaLocation="xsd0.xsd"/>

   <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" schemaLocation="xsd1.xsd"/>

</xsd:schema>

Then I disabled the serviceMetaData 'httpGetEnabled=False' in web.config, so the WebService would no longer generate the WSDL. If I was to give this WSDL out now to consumers I would give them the path to my custom local WSDL http://localhost:52038/Service1.wsdl

I'm sure there is more that could be said regarding this subject but I wanted to share what I did here. Disclaimer, this is just sample project regarding a general POC for something. Thank you!

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