2

I am using gSOAP to create C++ code from a WSDL document. The problem is gSOAP is giving me errors when I run the wsdl2h tool on my WSDL file. The errors are all related to namespace issues. For example

Warning: could not find element 'GetRPCMethods' type '"http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd":GetRPCMethods' in schema urn:tr069

I have pasted the namespace definitions and an example of how they are used below. Anyone know where I am going wrong?

urn:tr069 is supposed to refer to the current document.

<s0:definitions 
    name="tr069"
    xmlns:s0="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:s1="urn:tr069"
    xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/"
    targetNamespace="urn:tr069">

<s0:types>

<xsd:schema 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:tns="urn:tr069" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd1="http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd"
    targetNamespace="urn:tr069">

  <xsd:import namespace="urn:dslforum-org:cwmp-1-2" schemaLocation="cwmp-1-2.xsd" />
  <xsd:element name="GetRPCMethods" type="xsd1:GetRPCMethods" />
</xsd:schema>
</s0:types>
<s0:message name="GetRPCMethods">
     <s0:part element="s1:GetRPCMethods" name="GetRPCMethods" />
</s0:message>
</s0:definitions>

I have a few other questions, as I understand it the target namespace does not have to point to a real location, it is just a convention for pointing to the current document, Is this correct? Also in cwmp-1-2.xsd there is an element called GetRPCMethods which contains a sequence containing another element. Is it best practice to use this whole element(GetRPCMethods) as a part for a message as I have above or should I define the specific parts of GetRPCMethods in the message?

Thank you.

toc777
  • 2,607
  • 2
  • 26
  • 37

3 Answers3

3

The problem was the elements defined in the <schema> tag. First I removed all the defined elements inside the <schema> tag because they were completely unnecessary anyway. Then I changed the namespace of the elements in the message parts from s1 to xsd1 to use the elements in cwmp-1-2.xsd instead of the ones I defined in the <schema> tag.

As for my other questions, the targetNameSpace does not have to point to a real uri, it is just a name for the namespace of this document. For my second question, I think it is probably best and easiest to use the whole schema element as the part for the message.

toc777
  • 2,607
  • 2
  • 26
  • 37
0

I notice that

<xsd:schema>

doesn't have a closing tag? Is the wsdl a well-formed XML Document?

Targetnamespace is the namespace of the instance document ie., the one for SOAP:Envelope.

javadeveloper
  • 783
  • 6
  • 15
  • Sorry, I didn't paste it to the question correctly, I have edited the question. Yes the document is well-formed. So targetNamespace can be anything? – toc777 Mar 01 '11 at 16:18
  • Yes, it could be any URI (URL or a URN) but make sure that it is meaningful. For example, if you decide to use URI and own the domain 'mydomain', I would prefer it to keep it like >http://mydomain/xml/types/item – javadeveloper Mar 02 '11 at 15:14
0

The error message says what's wrong, you don't have a definition of xsd1:GetRPCMethods, is this somewhere defined? s1:GetRPCMethods is looked up -> s1 is found to be urn:trn069 -> urn:trn069 is not unique which might be a problem -> urn:trn69 defines the element, GetRPCMethods which is of type xsd1:GetRPCMethods -> this type is not found.

I'm not sure if it is valid to use the same URI for the targetNamespace. Maybe that's causing additional problems.

Bernhard
  • 8,583
  • 4
  • 41
  • 42
  • Its defined in the schema element `xmlns:xsd1="http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd"` It seems to be reading in this file so I don't see why it can't find GetRPCMethods – toc777 Mar 01 '11 at 16:53
  • Are you sure it's reading this schema file? AFAIK, in general parsers don't open the namespace URI. Have you tried to use different target namespaces in your definitions and schema tags? – Bernhard Mar 02 '11 at 08:32
  • Yes, that is true but it will open any imported namespace that it doesn't already know about. I am explicitly importing the above namespace. – toc777 Mar 02 '11 at 11:26