I am trying to import a WSDL into a SOAP-UI project - which is a simple tool for testing SOAP calls. When I try and import the wsdl I get the following error:
WSDLException (at /wsdl:definitions/portType/wsdl:operation[1]/wsdl:input):
faultCode=UNBOUND_PREFIX: Unable to determine namespace of 'nrns:getDynamicsUploadQueueRequest
From inspecting the WSDL I see that there is no xmlns:nrns declaration under the definitions area. I read in a forum that I can resave the WSDL to disk and correct the WSDL. However, I'm an extreme SOAP noob and I don't know what the definition is supposed to be. I think that if I just add the following to the definitions area it should sort things out. Anyone know what I would replace those question marks with? Am I completely wrong in my approach?
xmlns:nrns="???"
I don't own or have control over the WSDL. The WSDL and XML are below for reference.
https://apps.net-results.com/soap/v1/NRAPI.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name='NRAPI' targetNamespace='https://apps.net-results.com/soap/v1'
xmlns:nrtypens="https://apps.net-results.com/soap/v1/NRAPI.xsd"
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
This is an error in the WSDL. It appears that the "nrns" is meant to be https://apps.net-results.com/soap/v1. Note that this is the targetNamespace of the WSDL, in the definitions element.
So just add
xmlns:nrns='https://apps.net-results.com/soap/v1'
in the definitions element, and you should be fine.
Namespaces are a way to associate your elements to a particular type to avoid name conflicts. Refer here http://www.w3schools.com/xml/xml_namespaces.asp
You can pretty much anything is ??? and that should solve your problem. It needn't be any valid URL because it's never going to go that URL on internet and check its validity.
However, I suggest you get the corrected WSDL from its owner and use that else later you may end up with problems regarding namespace mismatch wasting lot of time. For time being to continue with your testing you may pretty much put anything in <wsdl:definition> tag, something like:
xmlns:nrns="http://fakeurl.com"
p.s. Play with your imagination :)
Related
I'm trying to learn how to use WSDL's to call web services from a Grails project. I've been provided with the WSDL and some XML results for reference.
I've been able to generate Java code from the WSDL, and everything seems to be working correctly.
Here's the WSDL: http://www.restfulwebservices.net/rest/USAZipCodeService.svc?wsdl
And here is the XML: http://api.geonames.org/postalCodeSearch?placename=MN&username=demo
I am receiving this exception in my project:
ERROR client.WebServiceClientFactoryImpl$WSClientInvocationHandler - No namespace on "geonames" element.
javax.xml.ws.soap.SOAPFaultException: No namespace on "geonames" element.
It seems like it is saying that the XML returned isn't valid for SOAP? Am I missing/misunderstanding some pieces the puzzle here? It is all pretty new to me.
Edit:
I am trying to use a Grails plugin called cxf client: https://github.com/ctoestreich/cxf-client
It is configured with the following in Config.groovy (something could be wrong/missing here?):
wsdl = "http://www.restfulwebservices.net/wcf/USAZipCodeService.svc?wsdl"
namespace = "cxf.client.postalcode"
clientInterface = "cxf.client.postalcode.IPostalCodeService"
serviceEndpointAddress = "http://api.geonames.org/postalCodeSearch"
I guess you just sent the XML returned from http://api.geonames.org/postalCodeSearch?placename=MN&username=demo as a parameter to the web service. Obviously, from the WSDL description returned you can see there is no such element named geonames, so the SOAPFaultException exception is quite a fair result.
To fix it, you have to refer to the WSDL description carefully, to make sure the invoke method has the right parameters work with whatever defined in the USAZipCodeService WSDL description tags like <wsdl:operation> and <wsdl:message>.
Another issue: 2 different WSDLs were metioned in your invoker and Config.groovy. The former is a RESTful service, and the later is a SOAP one. They work with different invoke methods and parameters, so make sure your code has consistent invoker and parameters, too.
I've got a bunch of XML messages in a PostgreSQL 9.1.3 table, with a column content of type XML). They're not all the same "type", so I'm trying to extract the root type using a query like this:
SELECT xpath('name(/*)', content) FROM message;
as recommended by this answer to a similar SO question.
A sample message is:
<?xml version="1.0" encoding="UTF-8"?>
<WML version="6" xmlns="http://example.com/schemas/WML">...</WML>
For which case I'd hope to get the result '{WML}'. Unfortunately it just returns an empty array. Adding the namespaces parameter to xpath, or removing the namespace from the message, does not help.
A discussion on the PostgreSQL mailing lists seems to explain it as a bug in XPath handling in PostgreSQL. However that was in 2008, and a look at the PostgreSQL source shows that piece of code was changed in 2009. I'm not a PostgreSQL developer so I'm not confident that the bug is or is not a factor in my case.
But I'm wondering if there's a workaround, such as an alternative XPath expression that might work? I'd prefer not to have to resort to regular expressions to parse XML, though if you can suggest a short, punchy, robust RE then it would be better than nothing.
Clearly, this has not yet been solved as of June 2011.
I found this thread on pgsql-hackers that describes your problem exactly.
I don't know of a workaround for older versions, but this is fixed in PostgreSQL 9.2, so that's great.
(The likeliest workaround would likely to have been to write a function to parse the XML manually, but I'm glad I don't have to resort to that now!)
I'm simply trying to convert a WSDl into a number of different HTTP-requests from data supplied by the WSDL. I have read through a ton of similar questions, but none really provided an answer.
Some say to use SOAPUI - I am familiar with this application and do use it. But I need to create these HTTP-requests from the WSDL on my own.
Some say to try JAXWS - I looked at a number of tutorials on this as well as on Axis and these translate the WSDL into Java class bindings and you use those methods to test the web services. I really would like to just generate the HTTP-request myself so that at one point I can manipulate the request and send my own tests.
I started using wsdl4j to begin parsing the WSDL myself but would rather not go down this path until I'm absolutely sure I'm not reinventing the wheel. Seems to me there has been a need for this in past? But with WSDL4J and every other library I do not see a WSDL to Soap message translation.
Any suggestions would be very helpful. The goal is I want to be able to take a WSDL, examine it and create HTTP-SOAP requests for each method in the WSDL and be able to than test them for security issues. The first step is to create those requests!
When calling a SOAP web service you can use a static invocation or a dynamic invocation.
Static invocation means creating a stub from the WSDL and using that to perform the call. This creates all the "plumbing" code for you, but is tightly tied to just that web service and you can't use it for other web services with different contracts. For each WSDL you need to create another stub.
With dynamic invocation, you read the WSDL at runtime and figure out how to call the web service based on the info you get from the WSDL. Feed it multiple WSDLs and the client adapts.
The dynamic invocation is what SoapUI uses to generate the sample requests and responses.
It reads the WSDL you feed it, extracts the XML schema from the types section and generates XML instances. To do so, it uses Wsdl4j and XmlBeans under the hood.
Your decision to use Wsdl4j is good as it gives you control when parsing the WSDL. But also have a look at XmlBeans; it has some other tools you might find useful, like the schema to instance class for example.
If you need to see it in action (maybe debug it to see what's going on) you could create a quick dirty test with the SoapUI API:
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;
public class Test {
public static void main(String[] args) throws Exception {
WsdlProject project = new WsdlProject();
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?wsdl");
WsdlInterface wsdl = wsdls[0];
System.out.println(wsdl.getOperationByName("Add").createRequest(true));
System.exit(0); // just to clear up some threads created by the project
}
}
The message you should see printed (for the Add operation of the Calculator WS) would be something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:a>?</tem:a>
<tem:b>?</tem:b>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
Hope this helps you move beyond the first step.
Sorry if this sounds stupid but I'm really new to LiftWeb and just struggling with the basic stuff:)
So I have a parametrized site map entry in Lift's bootstrap. This should be for the view page of an object of type MyItem. The URL would be like: "/myitems/UUID".
Menu.param [UUID]("MyItemView", "MyItemView", p=>Full(UUID.fromString(p)), p=>p.toString) / "myitems"
This adds the sitemap entry correctly. If I go to "/myitems/NOT_AN_UUID", it will throw the "Invalid UUID" exception as expected. But if I go to "/myitems/UUID" I get 404.
I know that I need a view and a snippet class that takes UUID as parameter in order for this to work but I have no idea how to name these and where to place them.
Btw, how would one new to Lift learn something like this? From the hundreds of articles and samples out there I found many to mention more complex stuff but haven't seen any to mention a basic thing like this. Do you know any secret start-up documentation for human beings?
Update: To summarize in case all you see above is jibber-jabber :) HOW DOES LIFT LOCATE TEMPLATES/VIEWS/SNIPPETS FOR PARAMETRIZED MENU ENTRIES?
It was actually the obvious answer. The template name is obtained from the path and the snippet can be whatever you want as long as you call it from the template xml.
I need to get used to all this convention over configuration :) However it would be nice for someone to tell you what is the convention.
I'm working on an app that uses a web service. This is a private service so I cannot post the WSDL or generated code here so this is more of a question for some general advice rather than specifics.
I fed the WSDL into Sudz-c. The WSDL originally had some imports of XSD's that sudz-c would overlook so I copied these into the types section of the WSDL.
I use the generated code to make a request to the service but I'm finding that the request is missing a name space for the complex type objects I copied into the types section of the WSDL.
Again I know this is very general information but if anyone else has had a similar issue with Sudz it would be great to get your advice.
I know the thread has ended, but I found solution to this problem..
If a WSDL has external XSDs included/imported then YES, you are right to have those XSDs types copied over into WSDL (i.e. Directly EMBED it into WSDL rather than including/importing).. The generated Code is almost perfect in any sense since it generates types for XSD types as well.. but you might receive an ERROR (same error in multiple files).. which will be a missing BASE-Class of few request/response types.. after analyzing the code I realized that that missing namespace is nothing but the same SOAPObject object so I replaced that missing namespace with SOAPObject.h and used SOAPObject interface/class as the base class.
e.g. in my case
#include "SOAP.h"
#include "sudz.h"
#class sudz;
#interface sudzAbstractRequestType : sudz
{
}
(Note: 'sudz' is the unique name that you use when generate code using SUDZ-C website/project, in your case it can be different).
I changed the code to (everywhere in the project where this error was encountered):
#include "SOAP.h"
#include "SOAPObject.h"
#class SOAPObject;
//#include "sudz.h"
//#class sudz;
#interface sudzAbstractRequestType : SOAPObject//sudz
{
}
I hope this will help others... I was stuck for days but later got it working OK..
Happy Coding :)
One thing you might try is to make sure you fix your namespace in the actual service itself.
here is a link help get that done:
http://alensiljak.blogspot.com/2009/06/removing-httptempuriorg-namespace-from.html
Couldn't find an answer to this so ended up just hand coding the web service messages :(