Reputation: 3
I have several web services written in c# using Visual Studio 2010. I also have an Apipgee account and access the web services via an Apigee URL including an API key as a parameter.
Accessing the WSDL of the web services (via Apigee), I use a URL similar to that below:
https://myapi-prod.apigee.net/v1/myapi/Path/To/MyWebService.asmx?wsdl&apikey={myapikey}
The WSDL is returned successfully but under the binding information (below), the direct path to the web service is displayed. Originallty, I did not pick this up, but when adding firewall rules to block direct access to our server (api.mydomain.com in the example), I of course blocked any requests where people had used the WSDL.
My question is how can I change the address location in the WSDL? There is little point in having a service like Apigee where all it does is protects the WSDL.
<wsdl:service name="MyWebService">
<wsdl:port name="MyWebServiceSoap" binding="tns:MyWebServiceSoap">
<soap:address location="https://api.mydomain.com/Path/To/MyWebService.asmx" />
</wsdl:port>
<wsdl:port name="MyWebServiceSoap12" binding="tns:MyWebServiceSoap12">
<soap12:address location="https://api.mydomain.com/Path/To/MyWebService.asmx" />
</wsdl:port>
<wsdl:port name="MyWebServiceHttpGet" binding="tns:MyWebServiceHttpGet">
<http:address location="https://api.mydomain.com/Path/To/MyWebService.asmx" />
</wsdl:port>
<wsdl:port name="MyWebServiceHttpPost" binding="tns:MyWebServiceHttpPost">
<http:address location="https://api.mydomain.com/Path/To/MyWebService.asmx" />
</wsdl:port>
</wsdl:service>
Upvotes: 0
Views: 1548
Reputation: 103
In Apigee, you can have a policy that's part of your existing flow to replace the values in the wsdl file returned by your server.
For example, using a javascript policy in the response path, you can simply do a string search/replace to substitute the values you want to change. If you want to do it without js, then you could completely rewrite the wsdl using the ExtractVariables and AssignMessage policies.
Sample code for the js policy:
wsdl = context.getVariable("message.content");
wsdl = wsdl.replace("api.mydomain.com", "new-server.com", "g");
context.setVariable("message.content", wsdl);
Just fine tune the search/replace above for it to work in your case.
Some references:
Upvotes: 2